gpt4 book ai didi

elasticsearch - Elasticsearch 中的多 -"match-phrase"查询

转载 作者:行者123 更新时间:2023-11-29 02:44:01 25 4
gpt4 key购买 nike

这对我来说应该是显而易见的,但事实并非如此。下面的双赛只是第二阶段(本例为Cape Basin)

    "query": {
"match_phrase": {
"contents": {
"query": "St Peter Fm",
"query": "Cape Basin"
}
}
}

"query": {
"match_phrase": {
"contents": {
"query": ["St Peter Fm", "Cape Basin"]
}
}
}

当下面的错误出现时

    "query": {
"match_phrase": {
"contents": {
"query": "St Peter Fm"
},
"contents": {
"query": "Cape Basin"
}
}
}

我想匹配包含与输入的任一短语完全相同的所有文档。

最佳答案

您的第一个查询实际上不是有效的 JSON 对象,因为您两次使用相同的字段名称。

您可以使用 bool must or should query匹配两个或其中一个短语:

    PUT phrase/doc/1
{
"text": "St Peter Fm some other text Cape Basin"
}

//Match BOTH
GET phrase/_search
{
"query": {
"bool": {
"must": [
{"match_phrase": {"text": "St Peter Fm"}},
{"match_phrase": {"text": "Cape Basin"}}
]
}
}
}

//Match EITHER ONE
GET phrase/_search
{
"query": {
"bool": {
"should": [
{"match_phrase": {"text": "St Peter Fm"}},
{"match_phrase": {"text": "Cape Basin"}}
]
}
}
}

关于elasticsearch - Elasticsearch 中的多 -"match-phrase"查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30020178/

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