Just yesterday I started working with ElasticSearch and I'm pretty happy with how it works. There are just a few things I can't get my head wrapped around yet. See the situation below:
{id: 5, name: "Lorem ipsum dolor sit amet", number: "180005", customer: "Lorem ipsum", archived: false}
{id: 19, name: "New order", number: "180019", customer: "Lorem ipsum", archived: false}
{id: 27, name: "Businesscards", number: "180027", customer: "Lorem ipsum", archived: false}
When searching for 'Buisinesscards' (the exact name of record 27), the other two records have a higher score and are on top of the list.
I'm using a simple ngram setup like this:
Settings:
"analysis"=> [
"filter"=> [
"ngram_filter"=> [
"type"=> "ngram",
"min_gram"=> 2,
"max_gram"=> 20
]
],
"analyzer"=> [
"ngram_analyzer"=> [
"type"=> "custom",
"tokenizer"=> "standard",
"filter"=> [
"lowercase",
"ngram_filter"
]
]
]
],
Mapping:
'properties' => [
'id' => [
'type' => 'integer',
'index' => false,
],
'name' => [
'type' => 'text',
'analyzer' => 'ngram_analyzer',
],
'number' => [
'type' => 'text',
],
'customer' => [
'type' => 'text',
'analyzer' => 'ngram_analyzer',
],
'archived' => [
'type' => 'boolean',
],
]
Search:
'must' => [
'multi_match' => [
'query' => $this->builder->query,
'fields' => ['name', 'number', 'customer'],
]
]
What can I do to to get the record with the name 'Businesscards' at the top when searching for "businesscards"?