Fulltext search by phrase and sort by keyword


(Mateusz) #1

Hi,

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.


(David Pilato) #2

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?


(Mateusz) #3

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"]

                      }
               }
         }
    }
}'

(David Pilato) #4

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


(system) #5

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