我在ElasticSearch中尝试multi_match查询,但查询没有返回任何结果。查询是:
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":[]}}
我在以Dho开头的wardname字段中有价值,
{
_id: ObjectId("56f43c0344fc86e73b1170b0"),
title: "Constant road work",
approvalStatus: "approved",
subward: "56a6124244fc868a255fe3fe",
wardname: "Dhokali"
}
不确定为什么不归还任何东西。任何帮助非常感谢。
由于
答案 0 :(得分:1)
如果您要搜索以某些字符串开头的内容,则需要使用Phrase Prefix查询。请尝试以下查询。
curl -XPOST "http://localhost:9200/smartjn/feed_details/_search" -d'
{
"query" : {
"multi_match" : {
"query" : "Dho*",
"fields" : [ "title", "wardname" ],
"type': 'phrase_prefix"
}
}
}'