Elasticsearch:术语聚合输出中不区分大小写

时间:2018-03-29 02:28:45

标签: elasticsearch

我存储了像' AA'这样的有价值字段,但在搜索中使用字词聚合时,它会返回小写的值,如' aa'。

使用这样的aggs搜索时:

POST /113/_search
{
  "query": {
    "query_string": {
      "query": "Jack"
    }
  }, 
    "aggs" : {
      "gender" : {
        "terms" : {
        "field" : "gender"
        }
      },
      "grade" : {
        "terms" : {
            "field" : "grade",
            "order" : {"_count" : "asc"}
        }

      }
    }
}

这样的输出:

{
  "hits": {
    "total": 4,
    "max_score": 1.3862944,
    "hits": [
      {
        "_index": "113",
        "_type": "default_type",
        "_id": "1",
        "_score": 0.07419574,
        "_source": {
          "name": "Tome Jack",
          "grade": "AA",
          "gender": 1
        }
      }
    ]
  },
  "aggregations": {
    "grade": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": [
        {
          "key": "b",
          "doc_count": 1
        },
        {
          "key": "c",
          "doc_count": 1
        },
        {
          "key": "aa",
          "doc_count": 2
        }
      ]
    }
  }
}

为什么密钥会变成小写,例如' aa'而不是' AA'?如何将密钥作为其原始值。

属性设置如下:

       "grade": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword"
          }
        },
        "analyzer": "ik_max_word",
        "fielddata": true
      },

0 个答案:

没有答案