假设我查询:
POST /story/story/_search
{
"query":{
"bool":{
"should":[
{
"match":{
"termVariations":{
"query":"not driving",
"type":"boolean",
"operator":"AND"
}
}
},
{
"match":{
"termVariations":{
"query":"driving",
"type":"boolean",
"operator":"AND"
}
}
}
]
}
}
}
此查询由一个分析器或另外 3 个文档返回。 我如何判断哪个 should 子句被匹配? Elasticsearch 可以随结果一起返回匹配的短语吗?
谢谢!
最佳答案
这里最好的选择是 named queries 。 您可以为查询命名,并且每个文档都会提供匹配的查询的名称。
{
"query": {
"bool": {
"should": [
{
"match": {
"name.first": {
"query": "qbox",
"_name": "first"
}
}
},
{
"match": {
"name.last": {
"query": "search",
"_name": "last"
}
}
}
]
}
}
}
关于elasticsearch - 如何知道哪些关键字在elasticsearch中匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33674787/