I am trying to write a simple regexp query using elasticsearch in python that just won't work. Can anybody tell me where I'm going wrong ?
result = es.search(index="my-index", body={"query": {"regexp": {"Name": "Vi.*" }}})
The indexed document is a list of names with my name also in it (Vitthal Bhandari). The above query always yields empty results when it should return my name instead. The document is properly indexed and other queries work just fine. For instance a match query gives the required result.
result = es.search(index="my-index", body={"query": {"match": {"Name": "Vitthal" }}})
What is the problem with the regexp query that I'm writing that it won't give any result? Any suggestions?
The index mapping of "Name" field is something like this :
"Name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}