I'm trying to do a sort with Elastic Search
, but some fields have accentuation, such as city names, I tried to use fields with index not_analyzed
and with ptbr
of the second form:
{ "settings": { "analysis": { "analyzer": { "folding": { "tokenizer": "standard", "filter": [ "lowercase", "asciifolding" ] }, "analyzer_ptbr": { "tokenizer": "standard", "filter": [ "lowercase", "stemmer_plural_portugues", "asciifolding" ] } }, "filter": { "stemmer_plural_portugues": { "type": "stemmer", "name": "minimal_portuguese" } } } }, "mappings": { "post": { "properties": { "title": { "type": "multi_field", "fields": { "title": { "type": "string", "analyzer": "standard" }, "folded": { "type": "string", "analyzer": "folding" }, "raw": { "type": "string", "index": "not_analyzed" }, "ptbr": { "type": "string", "analyzer": "analyzer_ptbr" } } } } } }
When trying to sort with:
{ "query": { "match_all": {} }, "sort": [ { "title.ptbr": { "order": "asc" } } ] }
It is returned:
A bacate
Version of A cent  b B anana D ois neighbors
>
If you change to the raw field (not parsed):
{ "query": { "match_all": {} }, "sort": [ { "title.raw": { "order": "desc" } } ] }
Return:
 ngelo
V ersão de Acentuação
Banners
B banners banners
banners
Or, ignoring the accent can not sort by the first word of the sentence, if I keep the field as unanalyzed the special characters are considered the first in decreasing ordering, has anyone ever had this problem?
Thank you