Your problem is that your data is marked. This is useful for any search on your data. ES (by default) will split your message field into different parts so that they can be searched. For example, you can search for the word ERROR in your logs, so you probably would like to see results in messages such as "There was an error in your cluster" or " Error . If you do not analyze the data for this field with tokenizers , you will not You can search as follows.
This analyzed behavior is useful when you want to search for things, but does not allow grouping when different messages have the same content. This is your business. The solution to this is to update your mapping by putting not_analyzed for that particular field that you don't want to split into tokens. This will probably work for your host field, but will probably break the search.
What I usually do for such situations is to use index patterns and multifields . The index pattern allows me to set up a mapping for each index that matches the regular expression, and multilevel fields allow me to have the behavior analyzed and not_analyzed in one field.
Using the following query will complete the task for your problem:
curl -XPUT https://example.org/_template/name_of_index_template -d ' { "template": "indexname*", "mappings": { "type": { "properties": { "field_name": { "type": "multi_field", "fields": { "field_name": { "type": "string", "index": "analyzed" }, "untouched": { "type": "string", "index": "not_analyzed" } } } } } }'
And then in the terms panel, you can use field.untouched to look at the entire content of the field when calculating the number of different elements.
If you donβt want to use index templates (perhaps your data is in the same index), setting a mapping to the Put Mapping API would do the job. And if you use multifields, there is no need to reindex the data, because from the moment a new mapping is set for the index, the new data will be duplicated in these two subfields ( field_name and field_name.untouched ). If you simply change the display from analyzed to not_analyzed , you will not be able to see any changes until you flip all your data.
source share