Elasticsearch lookup and relevance

I am trying to apply a template to a dropdown list of offers. I have a few days since I try to find out. :(

I have a list of restaurants (4000-7000). I want to search with wildcards in the names of restaurants and first display the search results in front of the text.

I tried to index the name field without an analyzer, with an ngram analyzer and many other solutions that I found on the net, but without any luck.

The best results so far I get with this setting:

settings:
  analysis: {
    analyzer: {
      default: {
        tokenizer: :keyword, 
        filter: [:lowercase]
      }
    }
  }

And the index name field is like this:

indexes :name, type: :string, analyzer: :default

: : {wildcard: {name: '* le *'}}
: , -, , , , , -BQ, , - -, . (Lincoln Park), - Streeterville, - Brewpub - Wrigleyville, Tweet... Let Eat!, Arco de Cuchilleros, Al # 1 -

, , " le", , . , . * , , , . , "Le Colonial", "Le Petit Paris", "Les Nomades" .

?

: . , , , - ngram .

+4
1

boost, .

curl -XPOST "http://hostname:9200/index/type/_search" -d'
{
"size": 2000,
"query": {
    "bool": {
        "should": [
            {
                "wildcard": {
                    "name": {
                        "value": "*le*"
                    }
                }
            },
            {
                "wildcard": {
                    "name": {
                        "value": "le*",
                        "boost": 5
                    }
                }
            }
        ]
    }
}
}'

curl -XPOST "http://hostname:9200/index/type/_search" -d'
{
"size": 2000,
"query": {
    "bool": {
        "should": [
            {
                "wildcard": {
                    "name": {
                        "value": "*le*"
                    }
                }
            },
            {
                "prefix": {
                    "name": {
                        "value": "le",
                        "boost": 2
                    }
                }
            }
        ]
    }
}
}'
+10

Source: https://habr.com/ru/post/1537358/


All Articles