I have an index with documents with the name property. My target document has the following value : "name" : "Eiker Football Team Crows"
. There are quite a few with "Eiker" somewhere in their name as it is a region. Searches for Football Team
finds this document and so does eik football team
or even eike
(though it finds others too). What is really weird is that Eiker
finds NONE of the documents with the word, but does suggest some with permutations like Eker
or Eikeland
. Literally searching for the full correctly spelled and cased name as the document I am looking for, does NOT find it.
This is the search I am trying to do as written in Kibana developer:
GET orgs/_search
{
"query": {
"match": {
"name": {
"query": "eiker",
"operator": "and",
"fuzziness": "auto",
"max_expansions": 5,
"prefix_length": 0
}
}
}
}
Why does my Elastic search hate r
?
I have tried different values of expansions or prefixes. Or or
instead of and
operator.
CodePudding user response:
Simple answer of your question is you are using fuzziness
so it will do the fuzzy matching as well. Please check this documentation.
fuzziness allows fuzzy matching based on the type of field being queried.
Also, Elasticsearch return top 10 result only by default. If you want to get more result then set size
param value to large number.
Update:
As per your comment, you are using autocomplete
as index time analyzer and autocomplete_search
as search time analyzer so thats why result are not coming. Try the below query with same analyzer which is use at index time for name
field and it should return result. (Please add your index mapping and analyzer setting in question so it will easy to answer question)
POST sampleindex/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"name": {
"query": "Eiker",
"operator": "and",
"fuzziness": "auto",
"max_expansions": 5,
"prefix_length": 0,
"analyzer": "autocomplete"
}
}
}
]
}
}
}