Hi,
I am using match phrase prefix for suggestion and querying search result. I'm using this for searching employee name, skill name, etc... basically name / title field which is not long.
When I'm searching name like "john d", I'm expecting results such as ["John Doe", "John Dwayne McKinsey", ...] but no results due to the limitation of max_expansions
.
Match phrase prefix is as the name suggest, the combination of match phrase and prefix. Hence I'm wondering if I can substitute the query with below snippet.
2 words - 'john d'
{
query: {
bool: {
must: [
{
match_phrase: { name: 'john' },
},
{
prefix: { name: 'd' },
}
]
}
}
}
3 words - 'john dwayne m'
{
query: {
bool: {
must: [
{
match_phrase: { name: 'john dwayne' },
},
{
prefix: { name: 'm' },
}
]
}
}
}
or if there's only one word, only prefix is used
{
query: {
bool: {
must: [
{
prefix: { name: 'joh' },
}
]
}
}
}
I need opinion on above substitute query and whether it will have hidden issue or not?
To note:
This works on my case where the terms/words order is somewhat unimportant. As far as I observe, the response time between match_phrase_prefix
and above query are no different.
Thank you