Reputation: 6185
I'm wondering why Elasticsearch
doesn't give me any results for the following Multi Match Query:
GET /stag/_search
{
"query": {
"multi_match": {
"type": "phrase_prefix",
"query": "ferran ma",
"fields": [ "fullName", "fullName.folded" ]
}
}
}
But it gives me results on:
GET /stag/_search
{
"query": {
"multi_match": {
"type": "phrase_prefix",
"query": "ferran may",
"fields": [ "fullName", "fullName.folded" ]
}
}
}
I thought that maybe there is a minimum character length per word but then I've seen the following query:
GET /stag/_search
{
"query": {
"multi_match": {
"type": "phrase_prefix",
"query": "ignasi t",
"fields": [ "fullName", "fullName.folded" ]
}
}
}
Is giving me results. So I have no idea what's going on.
Upvotes: 4
Views: 871
Reputation: 6185
Seems like the problem is explained here
The match_phrase_prefix query is a poor-man’s autocomplete. It is very easy to use, which lets you get started quickly with search-as-you-type but its results, which usually are good enough, can sometimes be confusing.
Consider the query string quick brown f. This query works by creating a phrase query out of quick and brown (i.e. the term quick must exist and must be followed by the term brown). Then it looks at the sorted term dictionary to find the first 50 terms that begin with f, and adds these terms to the phrase query.
The problem is that the first 50 terms may not include the term fox so the phrase quick brown fox will not be found. This usually isn’t a problem as the user will continue to type more letters until the word they are looking for appears.
Upvotes: 1