社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Elasticsearch

ElasticSearch多层嵌套属性

Galust • 3 年前 • 422 次点击  

我有一个这样的索引映射

"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
 
422 次点击