Py学习  »  Elasticsearch

ElasticSearch多层嵌套属性

Galust • 3 年前 • 404 次点击  

我有一个这样的索引映射

"mappings": {
      "properties": {
        "filter": {
          "type": "nested",
          "properties": {
            "Hersteller": {
              "type": "nested",
              "properties": {
                "id": {
                  "type": "text",
                  "analyzer": "analyzerFilter",
                  "fielddata": true
                },
                "value": {
                  "type": "text",
                  "analyzer": "analyzerFilter",
                  "fielddata": true
                }
              }
            },
            "Modell": {
              "type": "nested",
              "properties": {
                "id": {
                  "type": "text",
                  "analyzer": "analyzerFilter",
                  "fielddata": true
                },
                "value": {
                  "type": "text",
                  "analyzer": "analyzerFilter",
                  "fielddata": true
                }
              }
            }
          }
        },
        "id": {
          "type": "text",
          "analyzer": "analyzerFilter"
        }
      }
    }
  }

过滤器有两个嵌套层。莫德尔。我需要一个查询来获取所有唯一的筛选器。莫德尔。值在哪里过滤。赫斯特勒。值等于某个预定义的值。 我先试试,没有任何条件

{
  "size": 4,
  "aggs": {
    "distinct_filter": {
      "nested": { "path": "filter" },
      "aggs": {
        "distinct_filter_modell": {
          "nested": {
            "path": "filter.Modell",
            "aggs": {
              "distinct_filter_modell_value": {
                "terms": { "field": "filter.Modell.value" }
              }
            }
          }
        }
      }
    }
  }
}
 

我遇到了这样的问题

{
  "error": {
    "root_cause": [
      {
        "type": "parsing_exception",
        "reason": "Unexpected token START_OBJECT in [distinct_filter_modell].",
        "line": 1,
        "col": 144
      }
    ],
    "type": "parsing_exception",
    "reason": "Unexpected token START_OBJECT in [distinct_filter_modell].",
    "line": 1,
    "col": 144
  },
  "status": 400
}

提前感谢

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/132506
 
404 次点击