Facets using multivalued fields in Elasticsearch

24 views Asked by At

Below an exemple of the facets I have for the moment for the field "attr_matiere_du_manche"

{"attr_matiere_du_manche":{"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[{"key":"Bimatière","doc_count":5},{"key":"Bimatière,Bois","doc_count":1},{"key":"Plastique","doc_count":1}]}}

I'd like to separate "Bimatière,Bois", e.g.

{"attr_matiere_du_manche":{"doc_count_error_upper_bound":0,"sum_other_doc_count":0,"buckets":[{"key":"Bimatière","doc_count":6},{"key":"Bois","doc_count":1},{"key":"Plastique","doc_count":1}]}}

I tried to use a custom filter

{"split_values":{"type":"pattern_capture","preserve_original":true,"patterns":["([^,]+)"]}}

And a custom analyzer

{"split_attr":{"filter":["asciifolding","french_elision","lowercase","synonym","french_stop","split_values"],"tokenizer":"standard"}}

Here is the mapping of this field

{"attr_matiere_du_manche":{"type":"keyword","store":true,"fields":{"raw":{"type":"keyword","store":true},"split":{"type":"text","store":true,"analyzer":"split_attr"}}}}

I'm using Elasticsearch 7.17.9.

Do you know how can I separate the values?

Thanks

0

There are 0 answers