gpt4 book ai didi

elasticsearch - elasticsearch如何在匹配短语中包含同一字段的多个值

转载 作者:行者123 更新时间:2023-12-02 22:16:59 26 4
gpt4 key购买 nike

这是我的查询

GET blablabla/_search
{
"query": {
"bool": {
"must": [
{"match" : {"source" : "balblabla"}},
{"match" :{"blablablab" : "JBR"}},
{"match": {"city" : "blab bla"}},
{"match" : {"something": ["Balcony" , "Gym"]}}
]
}
}
}

我收到此错误:
{
"error": {
"root_cause": [
{
"type": "query_parsing_exception",
"reason": "[match] query parsed in simplified form, with direct field name, but included more options than just the field name, possibly use its 'options' form, with 'query' element?",
"index": "index name goes here",
"line": 8,
"col": 35
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "index name goes here",
"node": "4Qjq5UGPSZO2Qtg-ECI_mQ",
"reason": {
"type": "query_parsing_exception",
"reason": "[match] query parsed in simplified form, with direct field name, but included more options than just the field name, possibly use its 'options' form, with 'query' element?",
"index": "index name goes here",
"line": 8,
"col": 35
}
}
]
},
"status": 400
}

当我删除此行
{"match" : {"something": ["Balcony" , "Gym"]}}
它工作正常,但是为什么该行会导致解析错误,因为json中的数组很好?

我的elasticsearch版本是2.2

最佳答案

错误来自解析器,传递多个指针时必须指定“或”。

要解决您的情况,您必须更换

    {
"match": {
"something": [
"Balcony",
"Gym"
]
}
}


{
"match": {
"something": "Balcony OR Gym"
}
}

所以最后应该看起来像这样:
{
"query": {
"bool": {
"must": [
{
"match": {
"source": "balblabla"
}
},
{
"match": {
"blablablab": "JBR"
}
},
{
"match": {
"city": "blab bla"
}
},
{
"match": {
"something": "Balcony OR Gym"
}
}
]
}
}
}

希望这会对您有所帮助,并为您指明正确的道路:)

问候,
丹尼尔

关于elasticsearch - elasticsearch如何在匹配短语中包含同一字段的多个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35384830/

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