此tutorial(Ngrams for Compound Words)表示明智地使用minimum_should_match参数可以删除这些虚假结果。 我一步一步地学习本教程。除了最后一步,我在每一步都得到了相同的结果。
就我而言,minimum_should_match参数无法删除这些虚假结果。
测试:
curl -XGET http://localhost:9200/my_index/my_type/_search?pretty -d '
{
"query": {
"match": {
"text": {
"query": "Gesundheit",
"minimum_should_match": "80%"
}
}
}
}
'
响应:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 3,
"max_score": 5.215484,
"hits": [
{
"_index": "my_index",
"_type": "my_type",
"_id": "4",
"_score": 5.215484,
"_source": {
"text": "Weltgesundheitsorganisation"
}
}
,
{
"_index": "my_index",
"_type": "my_type",
"_id": "2",
"_score": 0.28685358,
"_source": {
"text": "Militargeschichte"
}
}
,
{
"_index": "my_index",
"_type": "my_type",
"_id": "5",
"_score": 0.28685358,
"_source": {
"text": "Rindfleischetikettierungsuberwachungsaufgabenubertragungsgesetz"
}
}
]
}
}
为什么在我的情况下,minimum_should_match参数没有删除这些虚假结果?不确定我可能错在哪里。
注意:在Elasticsearch 2.4.4和5.0.1上运行它。
修改 查询说明:
{
"valid": true,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"explanations": [
{
"index": "my_index",
"valid": true,
"explanation": "+(text:ges text:esu text:sun text:und text:ndh text:dhe text:hei text:eit) #ConstantScore(+ConstantScore(_type:my_type))"
}
]
}
{
"took": 20,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 3,
"max_score": 5.7275248,
"hits": [
{
"_shard": 0,
"_node": "_cVmNZULS3C-yMl4o6FobA",
"_index": "my_index",
"_type": "my_type",
"_id": "4",
"_score": 5.7275248,
"_source": {
"text": "Weltgesundheitsorganisation"
},
"_explanation": {
"value": 5.7275243,
"description": "sum of:",
"details": [
{
"value": 5.7275243,
"description": "sum of:",
"details": [
{
"value": 0.34488404,
"description": "weight(text:ges in 3) [PerFieldSimilarity], result of:",
"details": ...
}
,
{
"value": 0.7689487,
"description": "weight(text:esu in 3) [PerFieldSimilarity], result of:",
"details": ...
}
,
{
"value": 0.7689487,
"description": "weight(text:sun in 3) [PerFieldSimilarity], result of:",
"details": ...
}
,
{
"value": 0.7689487,
"description": "weight(text:und in 3) [PerFieldSimilarity], result of:",
"details": ...
}
,
{
"value": 0.7689487,
"description": "weight(text:ndh in 3) [PerFieldSimilarity], result of:",
"details": ...
}
,
{
"value": 0.7689487,
"description": "weight(text:dhe in 3) [PerFieldSimilarity], result of:",
"details": ...
}
,
{
"value": 0.7689487,
"description": "weight(text:hei in 3) [PerFieldSimilarity], result of:",
"details": ...
}
,
{
"value": 0.7689487,
"description": "weight(text:eit in 3) [PerFieldSimilarity], result of:",
"details": ...
}
]
}
,
{
"value": 0,
"description": "match on required clause, product of:",
"details": ...
}
]
}
}
,
{
"_shard": 0,
"_node": "_cVmNZULS3C-yMl4o6FobA",
"_index": "my_index",
"_type": "my_type",
"_id": "2",
"_score": 0.34488404,
"_source": {
"text": "Militargeschichte"
},
"_explanation": {
"value": 0.34488404,
"description": "sum of:",
"details": [
{
"value": 0.34488404,
"description": "sum of:",
"details": [
{
"value": 0.34488404,
"description": "weight(text:ges in 1) [PerFieldSimilarity], result of:",
"details": ...
}
]
}
,
{
"value": 0,
"description": "match on required clause, product of:",
"details": ...
}
]
}
}
,
{
"_shard": 0,
"_node": "_cVmNZULS3C-yMl4o6FobA",
"_index": "my_index",
"_type": "my_type",
"_id": "5",
"_score": 0.34488404,
"_source": {
"text": "Rindfleischetikettierungsuberwachungsaufgabenubertragungsgesetz"
},
"_explanation": {
"value": 0.34488404,
"description": "sum of:",
"details": [
{
"value": 0.34488404,
"description": "sum of:",
"details": [
{
"value": 0.34488404,
"description": "weight(text:ges in 4) [PerFieldSimilarity], result of:",
"details": ...
}
]
}
,
{
"value": 0,
"description": "match on required clause, product of:",
"details": ...
}
]
}
}
]
}
}
索引设置:
{
"my_index": {
"aliases": { },
"mappings": {
"my_type": {
"properties": {
"text": {
"type": "string",
"analyzer": "trigrams"
}
}
}
},
"settings": {
"index": {
"creation_date": "1486975897911",
"analysis": {
"filter": {
"trigrams_filter": {
"type": "ngram",
"min_gram": "3",
"max_gram": "3"
}
},
"analyzer": {
"trigrams": {
"filter": [
"lowercase"
,
"trigrams_filter"
],
"type": "custom",
"tokenizer": "standard"
}
}
},
"number_of_shards": "1",
"number_of_replicas": "1",
"uuid": "d-UluLwqSiOQjmYTwJze8w",
"version": {
"created": "2040199"
}
}
},
"warmers": { }
}
}
我的Elasticsearch应用位于 http://35.184.69.214/elasticsearch-head/
用户:用户
密码:elasticsearch