Reputation: 8881
I am trying a multi_match query in ElasticSearch but the query is returning no results. The query is:
curl -XPOST "http://localhost:9200/smartjn/feed_details/_search" -d'
{
"query" : {
"multi_match" : {
"query" : "Dho*",
"fields" : [ "title", "wardname" ]
}
}
}'
{"took":11,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}
I have value in wardname field starting with Dho,
{
_id: ObjectId("56f43c0344fc86e73b1170b0"),
title: "Constant road work",
approvalStatus: "approved",
subward: "56a6124244fc868a255fe3fe",
wardname: "Dhokali"
}
not sure why is it not returning anything. Any help greatly appreciated.
Thanks
Upvotes: 0
Views: 1100
Reputation: 12672
You need to use Phrase Prefix query if you want to search something that starts with some string. Try following query.
curl -XPOST "http://localhost:9200/smartjn/feed_details/_search" -d'
{
"query" : {
"multi_match" : {
"query" : "Dho*",
"fields" : [ "title", "wardname" ],
"type': 'phrase_prefix"
}
}
}'
Upvotes: 1