elasticsearch - Elasticsearch:嵌套映射在搜索上引发错误

标签 elasticsearch nested-queries

下面的快照是不言自明的,但这是我正在尝试做的事情。我有一个双嵌套的 stream.tagging.tag ,它是使用新映射重新创建索引的。但是,当我执行搜索时,ES无法找到内部嵌套字段的路径。

nishant-osx:~ nishagar$ curl GET 'localhost:9200/stream_rules/_mappings?pretty'
{
  "stream_rules": {
    "mappings": {
      "stream_rule": {
        "properties": {
          "stream": {
            "type": "nested",
            "properties": {
              "tagging": {
                "type": "nested",
                "properties": {
                  "displayName": {
                    "type": "string"
                  },
                  "tag": {
                    "type": "string",
                    "index": "not_analyzed",
                    "store": true
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

nishant-osx:~ nishagar$ CURL 'localhost:9200/stream_rules/_search' -d '{
>     "query": {
>         "nested" : {
>             "path" : "stream",
>             "query" : {
>                 "nested": {
>                     "path": "tagging",
>                     "query": {
>                         "bool" : {
>                         "must" : { "match" : {"stream.tagging.tag" : "product"} }
>                         }
>                     }
>                 }
>             }
>         }
>     }
> }'
{"error":"SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[Xh51BRC6SXekokw5jD5IzQ][stream_rules][0]: SearchParseException[[stream_rules][0]...
QueryParsingException[[stream_rules] [nested] failed to find nested object under path [tagging]]; }]","status":400}

最佳答案

查询中的嵌套路径不正确。

{
 "query": {
    "nested": {
        "path": "stream",
        "query": {
            "nested": {
                "path": "stream.tagging",
                "query": {
                    "bool": {
                        "must": {
                            "match": {
                                "stream.tagging.tag": "product"
                            }
                        }
                    }
                }
            }
        }
    }
  }
}

关于elasticsearch - Elasticsearch:嵌套映射在搜索上引发错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47345427/

相关文章:

elasticsearch - 如何更新Elasticsearch索引中的特定字段?

elasticsearch - 在内部列表上查询Elasticsearch并仅从列表中获取匹配的对象,而不是结果文档中的整个列表

java - 在 gradle build 中启动 elasticsearch 以进行集成测试

elasticsearch - 嵌套聚合查询中的嵌套聚合

SQL 子查询优化

elasticsearch - elasticsearch nest似乎不支持功能分数中的提升因子

elasticsearch - 弹性分析器以启用匹配搜索,例如C#,C++,A +

LINQ 抛出查询嵌套太深异常

elasticsearch - Elasticsearch 查询,用于从文档中检索对象数组的特定对象