gpt4 book ai didi

elasticsearch - 如何知道Elasticsearch中匹配的关键字

转载 作者:行者123 更新时间:2023-12-02 22:24:29 25 4
gpt4 key购买 nike

说我查询:

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个文档返回。
我如何知道哪个应该匹配的子句? 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com