elasticsearch,lucene,aggregation,nest,C#,elasticsearch,Lucene,Aggregation,Nest" /> elasticsearch,lucene,aggregation,nest,C#,elasticsearch,Lucene,Aggregation,Nest" />

C# Elasticsearch计数项忽略大小写

C# Elasticsearch计数项忽略大小写,c#,elasticsearch,lucene,aggregation,nest,C#,elasticsearch,Lucene,Aggregation,Nest,以下是我的总结 { "size": 0, "aggs": { "cities": { "terms": { "field": "city.raw" } } } 映射 "properties": { "state" : { "type": "string", "fields": { "raw" : { "type"

以下是我的总结

{
    "size": 0,
    "aggs": {
        "cities": {
            "terms": {
               "field": "city.raw"
           }
    }
}
映射

"properties": {
    "state" : {
      "type": "string",
      "fields": {
        "raw" : {
          "type": "string",
          "index": "not_analyzed"
        }
      }
    }
效果很好。但考虑到案例敏感性,它将字段分组

例如

我希望结果是这样的

{
    "key": "new york",
    "doc_count": 100
}

我认为问题在于你使用了索引字符串的原始版本

city.raw
你的档案没有经过分析的版本吗? 如果您还将字段的映射放在示例中,那就太好了

更新:你应该使用一个定制的分析器来满足你的需要。标记器应为关键字,过滤器应为小写。然后使用此分析器为数据编制索引。那就行了

            "analyzer": {
                "my_analyzer": {
                    "type":         "custom",                       
                    "tokenizer":    "keyword",
                    "filter":       "lowercase"
                }   
            }

还有一些信息和

为问题添加了映射。是的,谢谢。另一个小查询我是否需要重新创建索引以添加分析器,因为如果我尝试更新它,我会收到一条错误消息,说明该索引已存在。因此,我使用分析器重新创建了整个索引,并添加了映射,然后为数据设定种子。如果我能添加映射并更新它就好了是的。如果要添加新的analyzer,必须重新创建索引。
            "analyzer": {
                "my_analyzer": {
                    "type":         "custom",                       
                    "tokenizer":    "keyword",
                    "filter":       "lowercase"
                }   
            }