Reputation: 343
a newbie to ES needs helping hands for the Suggester.... I made a simple index with some titles like "Manufacturer product name mpn":
My current Mapping:
'suggest'=> [
'=> 'completion'
'=> 'simple'
' => false
]
my current Query:
'body' => [
'suggest' => [
'text' => $this->query
, 'completion' => [
'field' => 'suggest'
]]]
Now if I try to Suggest it works, but results are very ugly.... Perhaps somebody can help me to find the right settings:
e.g. a title is: "Xoar Electric Beechwood Precision"
Now i want this results for Queries:
"X" => "Xoar"
"Yoar E" => "Xoar", "Xoar Electric"
"El" => "Electric"
"Elektric " => "Electric", "Electric Beechwood"
At the moment it only returns the full title if I type "X...."
Is this possible? And if yes, how can i try to get this results?
THANKS in advance!
Upvotes: 0
Views: 144
Reputation: 180
You should use ngrams
approach i.e. tokenize your words by splitting them with space character or what suits your use case the most. Then index each token with the suggest analyzer.
Split "Xoar Electric Beechwood Precision" like this
And then use the prefix
query. For auto-correcting, you may use fuzziness
parameter.
Hope this helps.
Upvotes: 0
Reputation: 8065
You need to change default tokenizer and analyzer to fetch related documents from elasticsearch.
Check below links for more details which talks about how to handle human language and typo corrections,
Human Languages with elasticsearch
Fuzzy matching with elasticsearch
Upvotes: 0