我有两个索引:
首先,questions
,具有嵌套字段answers
。其次,articles
没有此字段。
我尝试通过多个索引进行搜索:
{
"index": "questions, articles",
"body":{
"query":{
"bool":{
"must":{
"nested":{
"path": "answer",
...
}
}
}
}
}
}
并得到错误的
"query_parsing_exception: [nested] failed to find nested object under path [answer]"
当一个索引具有嵌套字段,而另一个索引没有嵌套字段时,如何进行无错误搜索?
最佳答案
我认为您需要使用 indices
query并对每个索引使用不同的查询。像这样:
GET /questions,articles/_search
{
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"indices": {
"indices": [
"questions"
],
"query": {
"nested": {
"path": "answer",
"query": {
"term": {
"text": "bla"
}
}
}
}
}
},
{
"match_all": {}
}
]
}
},
{
"term": {
"some_common_field": {
"value": "whatever"
}
}
}
]
}
}
}
关于php - 使用嵌套字段进行多索引搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38975754/