我有以下查询:
{
"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
部分,它会按预期工作。
不可能拥有普通的'和嵌套查询在同一个请求中,或者我只是做错了?
答案 0 :(得分:1)
你需要这样写:
{
"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"
}
}
}
}
]
}
}
}