I am trying to write a query in ElasticSearch which matches contiguous characters in the words. So, if my index has "John Doe", I should still see "John Doe" returned by Elasticsearch for the below searches.
1.john doe
2.john do
3.ohn do
4.john
5.n doe
I have an ngram analyzer on my data with a mingram:2 and maxgram:10.
I have tried the below query so far. Is ngram the way to go here or am I missing something. Please note that searching "jo oe" should NOT return "John Doe" result.
{
"query": {
"multi_match": {
"query": "term",
"operator": "AND",
"type": "phrase_prefix",
"max_expansions": 50,
"fields": [
"Field1",
"Field2"
]
}
}
}