Elasticsearch count terms ignoring spaces

后端 未结 2 1972
天命终不由人
天命终不由人 2021-02-06 04:41

Using ES 1.2.1

My aggregation

{
    \"size\": 0,
    \"aggs\": {
        \"cities\": {
            \"terms\": {
                \"field\": \"city\",\"siz         


        
2条回答
  •  野性不改
    2021-02-06 05:30

    For fields that you want to perform aggregations on I would recommend either the keyword analyzer or do not analyze the field at all. From the keyword analyzer documentation:

    An analyzer of type keyword that "tokenizes" an entire stream as a single token. This is useful for data like zip codes, ids and so on. Note, when using mapping definitions, it might make more sense to simply mark the field as not_analyzed.

    However if you want to still perform analysis on the field to include for other searches, then consider using the field setting of ES 1.x As described in the field/multi_field documentation. This will allow you to have a value of the field for searching and one for aggregations.

提交回复
热议问题