我想调整以下查询,以便它与多个单词完全匹配。每当我尝试这个时,它似乎将字符串标记化然后搜索。如何为特定子字符串指定它必须是完全匹配?
{
"query": {
"query_string": {
"query": "string OR string2 OR this is my multi word string",
"fields": ["title","description"]
}
}
}
我的映射如下:
{
"indexname": {
"properties": {
"title": {
"type": "multi_field",
"fields": {
"title": {"type": "string"},
"original": {"type" : "string", "index" : "not_analyzed"}
}
},
"location": {
"type": "geo_point"
}
}
}
答案 0 :(得分:0)
默认情况下,QuerySring和匹配查询被分析。所以使用术语查询。但是我们不能在术语查询中使用多个字段。所以请使用bool查询。请尝试下面的查询..
{
"query": {
"bool": {
"must": [
{
"term": {
"title": {
"value": "string OR string2 OR this is my multi word string"
}
}
},
{
"term": {
"description": {
"value": "string OR string2 OR this is my multi word string"
}
}
}
]
}
}
}
它有帮助......!