问题是由于您正在使用该text
字段和match
查询。
对匹配查询进行分析,并使用与索引时使用的搜索词相同的分析器,对于字段,这是标准分析器text
。在您的情况下,如果在空白处打断文本,Landkreis Cloppenburg
将创建两个标记landkreis
,cloppenburg
同时创建索引和搜索时间,甚至cloppenburg
匹配文档。
解决方案:使用keyword field
。
{
"mappings": {
"properties": {
"location": {
"type": "keyword"
}
}
}
}
{
"query": {
"bool": {
"must": [
{
"match": {
"location": {
"query": "Cloppenburg"
}
}
}
]
}
}
}
"hits": [
{
"_index": "location",
"_type": "_doc",
"_id": "2",
"_score": 0.6931471,
"_source": {
"location": "Cloppenburg"
}
}
]