2
I’m trying to make an ordination with Elastic Search
, however some fields have accentuation, as name of cities, I tried to use fields with index not_analyzed
and with ptbr
in 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 order with:
{ "query": { "match_all": {} }, "sort": [ { "title.ptbr": { "order": "asc" } } ] }
Is returned:
Tobacty
Version of Tocentuação
ângelo
Banna
Dois Neighbours
Switch to raw field (not analyzed):
{ "query": { "match_all": {} }, "sort": [ { "title.raw": { "order": "desc" } } ] }
Returns:
ângelo
Versão de Acentuação
Two Vtiny
Banna
Tobacty
That is, ignoring the accent I cannot order by the first word of the sentence, if I keep the field as not analyzed the special characters are considered the first in the decreasing ordering, someone has already gone through this problem?
Thank you
I believe it worked, thank you
– Luiz Ribeiro Jr