gpt4 book ai didi

elasticsearch - 使用嵌套查询时出现 Elasticsearch 问题

转载 作者:行者123 更新时间:2023-12-03 01:50:24 26 4
gpt4 key购买 nike

我有以下查询:

{
"from": 0,
"size": 20,
"sort": {
"prices_count": "desc"
},
"query": {
"bool": {
"must": [{
"terms": {
"category_ids": ["3"]
}
}, {
"terms": {
"manufacturer_id": ["5"]
}
}, {
"range": {
"prices_count": {
"gte": 1
}
}
}]
},
"nested": {
"bool": {
"must": [{
"match": {
"specs.model": "iphone-6s"
}
}]
}
}
}
}

我收到以下错误:
Fatal error: Uncaught exception 'Elastica\Exception\ResponseException' with message 'failed to parse search source. expected field name but got [START_OBJECT]' in

如果我只在查询中保留 nested部分,它会按预期工作。

是否不可能在同一请求中使用“普通”和嵌套查询,还是我做错了?

最佳答案

您需要这样写:

{
"from": 0,
"size": 20,
"sort": {
"prices_count": "desc"
},
"query": {
"bool": {
"must": [
{
"terms": {
"category_ids": [
"3"
]
}
},
{
"terms": {
"manufacturer_id": [
"5"
]
}
},
{
"range": {
"prices_count": {
"gte": 1
}
}
},
{
"nested": {
"path": "specs",
"query": {
"match": {
"specs.model": "iphone-6s"
}
}
}
}
]
}
}
}

关于elasticsearch - 使用嵌套查询时出现 Elasticsearch 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40904637/

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