简体   繁体   English

多层嵌套文档上的Elasticsearch构面

[英]Elasticsearch facet on multi-level nested document

I'm trying to calculate facets in multi-level nested documents. 我正在尝试计算多层嵌套文档中的构面。 And could not find any example in docs or google, but found this: 并且无法在docs或google中找到任何示例,但是发现了这一点:

The nested element provides the path to the nested document (can be a multi level nested docs) that will be used. nested元素提供了将要使用的嵌套文档(可以是多层嵌套docs)的路径。 ( http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-facets.html#_all_nested_matching_root_documents ) http://www.elasticsearch.org/guide/zh-CN/elasticsearch/reference/current/search-facets.html#_all_nested_matching_root_documents

But the following query does not work. 但是以下查询不起作用。 What is the right way to query this facet? 查询此方面的正确方法是什么?

http://pastie.org/8526599 - here is the mapping i'm trying to use http://pastie.org/8526599-这是我尝试使用的映射

http://pastie.org/8526601 - and here is non-working query http://pastie.org/8526601-这是无效的查询

Solved. 解决了。 Correct syntax: 正确的语法:

{
  "facets": {
    "tf": {
      "terms": {
        "field": "fares.directions.orig.city"
      },
      "nested": "fares.directions"
    }
  }
}

SO - in nested inside facet definition we need to select the deepest nested path, and fields must be referenced by full path 所以-在嵌套内部构面定义中,我们需要选择最深的嵌套路径,并且字段必须由完整路径引用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM