Reputation: 4389
I want to match a document whose field title
has value brown fox
by searching with keyword brownfox
.
When trying this fuzzy
query I get no results:
curl -XGET 'http://localhost:9200/haystack/_search?pretty' -d '{
"query" : {
"fuzzy" : {
"title": {
"value": "brownfox",
"fuzziness": 2,
"prefix_length": 0,
"max_expansions": 10000
}
}
}
}'
I also tried a match
query with fuzziness and operator and
:
curl -XGET 'http://localhost:9200/haystack/_search?pretty' -d '{
"query": {
"match": {
"title": {
"query": "brownfox",
"fuzziness": "AUTO",
"operator": "and"
}
}
}
}'
This returns results with similar keywords, but not the document with title brown fox
which I would consider a better match.
I also read the answer to this SO question, but I don't have the option to update the analyzer of the field with synonyms, since I want to match other similar cases too, including both missing spaces and mis-spelled words.
Thanks!
Upvotes: 2
Views: 1465
Reputation: 52366
The mapping of that title
field should, at least, have an analyzer that would keep "brown fox"
as a single term. If it's using standard
analyzer or anything that is not keeping brown fox
as a whole you'll not be able to match that.
Upvotes: 1