elasticsearch 如何对包含空格的属性名执行elasticsearch聚合,elasticsearch,lucene,elasticsearch,Lucene" /> elasticsearch 如何对包含空格的属性名执行elasticsearch聚合,elasticsearch,lucene,elasticsearch,Lucene" />

elasticsearch 如何对包含空格的属性名执行elasticsearch聚合

elasticsearch 如何对包含空格的属性名执行elasticsearch聚合,elasticsearch,lucene,elasticsearch,Lucene,我正在尝试对包含空格的属性名运行聚合。 这就是搜索的查询主体 { "size": 0, "aggs": { "categoryId": { "filter": { "bool": { "filter": [ { "term": { "title.list": "iphone" } }

我正在尝试对包含空格的属性名运行聚合。 这就是搜索的查询主体

{
  "size": 0,
  "aggs": {
    "categoryId": {
      "filter": {
        "bool": {
          "filter": [
            {
              "term": {
                "title.list": "iphone"
              }
            }
          ]
        }
      },
      "aggs": {
        "results": {
          "terms": {
            "field": "category.l3.id",
            "size": 4
          },
          "aggs": {
            "categoryName": {
              "terms": {
                "field": "category.l3.id.keyword",
                "size": 1
              }
            }
            "Operating_System": {
              "terms": {
                "field": "detail.attribute.Operating System.raw",
                "size": 9
              }
            }
          }
        }
      }
    }
  }
}
正如您所看到的,属性名“Operating System”有一个空格。我试着这样跑

"field": "detail.attribute['Operating System'].raw"
它仍然不起作用。我该如何解决这个问题? 这是地图

 "detail": {
    "properties": {        
        "attribute": {
            "dynamic": "true",
            "properties": {               
                "Operating System": {
                    "type": "text",
                    "fields": {
                        "raw": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                }
            }
        }
    }
}

我让它工作了。显然,财产名称中的空格是合法的

"Operating_System": {
              "terms": {
                "field": "detail.attribute.Operating System.raw",
                "size": 9
              }
            }
我不知道它以前是如何工作的,也许我遗漏了一些东西,但此查询将返回一个响应

您需要在空格后面添加“\”以使其工作。 试着这样做

"detail": {
    "properties": {        
        "attribute": {
            "dynamic": "true",
            "properties": {               
                "Operating\ System": {
                    "type": "text",
                    "fields": {
                        "raw": {
                            "type": "keyword",
                            "ignore_above": 256
                        }
                    }
                }
            }
        }
    }
}

你能从你的索引中发布一个示例文档吗?@sramalingam24这里是文档的一部分,
“\u source:{”detail:{”attribute:{“operation System”:[“Windows 7 Home Premium”,2]}“attList”:[“operation System”]}