I have just started using Elasticsearch, version 7.5.1.
I want to query results which start with a particular word fragment. For example tho* should return data containing:
thought, Thomson, those, etc.
I tried with -
- Regexp
[{'regexp':{'f1':'tho.*'}},{'regexp':{'f2':'tho.*'}}]
- Wildcard
[{'wildcard':{'f1':'tho*'}},{'wildcard':{'f2':'tho*'}}]
- Prefix
[{'prefix':{'f1':'tho'}},{'prefix':{'f2':'tho'}}]
- match_phrase
'multi_match': {'query': 'tho', 'fields':[f1,f2,f3], 'type':phrase}
# also tried with type phrase_prefix
All those are returning correct results, but they all also return the word method.
Similarly cat* is returning the word communication.
What I am doing wrong? Is this something related to analyzer?
- Edit - Here is the field mapping -
'f1': {
'full_name': 'f1',
'mapping': {
'f1': {
'type': 'text',
'analyzer': 'some_analyzer',
'index_phrases': true
}
}
},