There is a “table” in Elasticsearch that looks like:

enter image description here

Now I make a request:

{ "size": 0, "aggregations": { "sport": { "terms": { "field": "prices.pharmacy.name" } } } } 

and get the answer:

 { "took": 2, "timed_out": false, "_shards": { "total": 30, "successful": 30, "failed": 0 }, "hits": { "total": 1999, "max_score": 0, "hits": [] }, "aggregations": { "sport": { "doc_count_error_upper_bound": 0, "sum_other_doc_count": 0, "buckets": [ { "key": "docmorris", "doc_count": 1000 }, { "key": "apotheke.com", "doc_count": 999 }, { "key": "shop", "doc_count": 999 } ] } } } 

How to make the shop and online.com in one "line" was?

 "aggregations": { "sport": { "doc_count_error_upper_bound": 0, "sum_other_doc_count": 0, "buckets": [ { "key": "docmorris", "doc_count": 1000 }, { "key": "shop-apotheke.com", "doc_count": 999 }, ] } 
  • As far as I understand, you have the analyzer enabled on the prices.pharmacy.name field, which allows you to search by words. Add a mapping field description. - Yuriy
  • when creating an index, put the field index: not_analyzed - etki
  • If you need an analyzer, try "field": "prices.pharmacy.name" replace with "script": "doc ['prices.pharmacy.name']. Value" in the settings script.inline: on - Yuriy must be enabled
  • one
    Solution: index: not_analyzed. Thank you all. - Alex Andr
  • @Alex Andr will be time to issue in the form of an answer to the question. - Yuriy

2 answers 2

because A frequently asked question, I will write as I did, I immediately say all of the above, through the Sense extension for chrome, for other cases you need a code correction, you can disable the analyzer like this

 POST Здесь_имя_index {"mappings": { "здесь_имя_type": { "_all": { "enabled": false }, "properties": { "поле_без_индексации1":{ "type":"string", "index" : "not_analyzed" }, "поле_без_индексации2":{ "type":"string", "index" : "not_analyzed" } } } } } 

    For the prices.pharmacy.name field in the mapping, you must specify type:keyword .

    In this case, the entire line will be considered as a single whole and analyzed without parsing.