0
所以我下面的語句建議者模板:Elasticsearch短語建議者整理返回false即使查詢結果帶來回
PUT /_search/template/DidYouMean
{
"template": {
"size": 0,
"suggest": {
"DidYouMean": {
"text": "{{SearchPhrase}}",
"phrase": {
"field": "_all",
"analyzer": "simple",
"size": 50,
"real_word_error_likelihood": 0.9,
"max_errors": 0.5,
"gram_size": 3,
"direct_generator": [
{
"field": "_all",
"suggest_mode": "always",
"min_word_length": 3
}
],
"collate": {
"prune": true,
"query": {
"match": {
"_all": {
"query": "{{suggestion}}"
}
}
}
}
}
}
}
}
}
我使用此查詢運行它:
POST /my_index/_search/template
{
"template": {
"id": "DidYouMean"
},
"params": {
"SearchPhrase": "unileve"
}
}
而且我很期待以"collate_match": true
作爲結果獲得聯合利華(一家公司),但是,它將帶回false
。我得到這個,雖然我很期待聯合利華來與真:
{
"took": 25,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 220692,
"max_score": 0,
"hits": []
},
"suggest": {
"DidYouMean": [
{
"text": "unileve",
"offset": 0,
"length": 7,
"options": [
{
"text": "unilever",
"score": 0.016954133,
"collate_match": false
},
{
"text": "unilevers",
"score": 0.005391976,
"collate_match": false
},
{
"text": "unilet",
"score": 0.00062763924,
"collate_match": false
},
{
"text": "uniline",
"score": 0.00062518474,
"collate_match": false
},
{
"text": "unilerver",
"score": 0.00055350363,
"collate_match": false
},
{
"text": "uniliver",
"score": 0.00055350363,
"collate_match": false
},
{
"text": "unielever",
"score": 0.0005243993,
"collate_match": false
}
]
}
]
}
}
現在,當我自己運行相同的查詢,它帶來的結果返回。
POST /my_index/_search
{
"query": {
"match": {
"_all": {
"query": "unilever"
}
}
}
}
它確實帶來了結果。
{
"took": 4,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 4305,
"max_score": 3.1709287,
"hits": [
{
"_index": "my_index",
"_type": "companies",
"_id": "754743",
"_score": 3.1709287,
"_source": {
"CompanyName": "Unilever Iran Co"
}
},
{
"_index": "my_index",
"_type": "companies",
"_id": "751585",
"_score": 3.1709287,
"_source": {
"CompanyName": "Unilever UK Ltd"
}
},
{
"_index": "my_index",
"_type": "companies",
"_id": "10363",
"_score": 3.1709287,
"_source": {
"CompanyName": "Unilever (Schweiz) AG"
}
},
{
"_index": "my_index",
"_type": "companies",
"_id": "647311",
"_score": 3.1709287,
"_source": {
"CompanyName": "Unilever Taiwan Ltd"
}
},
{
"_index": "my_index",
"_type": "companies",
"_id": "651158",
"_score": 3.1709287,
"_source": {
"CompanyName": "Unilever Gulf FZE"
}
},
{
"_index": "my_index",
"_type": "companies",
"_id": "654498",
"_score": 3.1709287,
"_source": {
"CompanyName": "Unilever China Ltd"
}
},
{
"_index": "my_index",
"_type": "companies",
"_id": "654664",
"_score": 3.1709287,
"_source": {
"CompanyName": "Unilever NV"
}
},
{
"_index": "my_index",
"_type": "companies",
"_id": "650307",
"_score": 3.1709287,
"_source": {
"CompanyName": "Unilever Canada Ltd"
}
},
{
"_index": "my_index",
"_type": "companies",
"_id": "710125",
"_score": 3.1709287,
"_source": {
"CompanyName": "Unilever Ltd"
}
},
{
"_index": "my_index",
"_type": "companies",
"_id": "722327",
"_score": 3.1709287,
"_source": {
"CompanyName": "Unilever Croatia"
}
}
]
}
}
我是否誤解了整理的目的?或者我只是在做一些完全錯誤的事情。請指教。
Elasticsearch版本:1.7.3