我正在使用elasticsearch,但很难实现精确匹配。我已经尝试了各种match、query_string等组合,但要么什么都没有返回,要么结果不佳。
查询看起来像这样:
{
"filter": {
"term": {
"term": "dog",
"type": "main"
}
},
"query": {
"match_phrase": {
"term": "Dog"
}
},
"sort": [
"_score"
]
}
排序后的结果
10.102211 {u'term': u'The Dog', u'type': u'main', u'conceptid': 7730506}
10.102211 {u'term': u'That Dog', u'type': u'main', u'conceptid': 4345664}
10.102211 {u'term': u'Dog', u'type': u'main', u'conceptid': 144}
7.147442 {u'term': u'Dog Eat Dog (song)', u'type': u'main', u'conceptid': u'5288184'}
我明白,“The Dog”、“That Dog”和“Dog”得分相同,但我需要找出如何提高“Dog”的精确匹配得分。
我也尝试过
{
"sort": [
"_score"
],
"query": {
"bool": {
"must": [
{
"match": {
"term": "Dog"
}
},
{
"match_phrase": {
"term": {
"query": "Dog",
"boost": 5
}
}
}
]
}
},
"filter": {
"term": {
"term": "dog",
"type": "main"
}
}
}
但那仍然只给我
11.887239 {u'term': u'The Dog', u'type': u'main', u'conceptid': 7730506}
11.887239 {u'term': u'That Dog', u'type': u'main', u'conceptid': 4345664}
11.887239 {u'term': u'Dog', u'type': u'main', u'conceptid': 144}
8.410372 {u'term': u'Dog Eat Dog (song)', u'type': u'main', u'conceptid': u'5288184'}