Fulltext search by phrase and sort by keyword


I've got problem with my elasticsearch.

I must do fulltext search by phrase ("name": "Abc cba", "name": "cba", "name": "hgf abc") if i search by "abc" I have "Abc cba" and "hgf abc" by if I have do sort on this field "name" I've got: (Abc cbd; hgf abc; cba) it's no good sort.

But if I use this field as keyword I've got good sort but no good search.

You can have multiple analysis strategy for the same field. So you can search in the "main" field but then sort using the keyword field.

Make sense?

Yes, but how I can do this ?

Like this?

"settings": {
"analysis": {
"analyzer": {
"default": {
"tokenizer": "standard",
"filter":  [ "standard", "asciifolding", "lowercase", "keyword_repeat", "porter_stem"]
  "default1": {
        "tokenizer": "keyword",
        "filter":  [ "standard", "asciifolding", "lowercase", "keyword_repeat"]


Read: https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.