我已經插入3條記錄在我的ElasticSearch指標如下:ElasticSearch查詢/檢索/匹配
curl -XPOST 'http://127.0.0.1:9200/geoindex_test/STREET?pretty=1' -d '
{ "cityNames" : [ { "language" : "ENG",
"name" : "w bridgewater",
"raw_name" : "W BRIDGEWATER"
},
{ "language" : "ENG",
"name" : "west bridgewater",
"raw_name" : "West Bridgewater"
}
],
"id" : 1,
"streetNames" : [ { "language" : "ENG",
"name" : "cram rd",
"raw_name" : "Cram Rd"
} ]
}'
curl -XPOST 'http://127.0.0.1:9200/geoindex_test/STREET?pretty=1' -d '
{ "cityNames" : [ { "language" : "ENG",
"name" : "bridgewater corners",
"raw_name" : "BRIDGEWATER CORNERS"
},
{ "language" : "ENG",
"name" : "bridgewater center",
"raw_name" : "Bridgewater Center"
}
],
"id" : 2,
"streetNames" : [ { "language" : "ENG",
"name" : "valley view rd",
"raw_name" : "Valley View Rd"
} ]
}'
curl -XPOST 'http://127.0.0.1:9200/geoindex_test/STREET?pretty=1' -d '
{ "cityNames" : [ { "language" : "ENG",
"name" : "bridgewater",
"raw_name" : "Bridgewater"
},
{ "language" : "ENG",
"name" : "windsor",
"raw_name" : "Windsor"
}
],
"id" : 3,
"streetNames" : [ { "language" : "ENG",
"name" : "valley view rd",
"raw_name" : "Valley View Rd"
} ]
}'
我執行搜索如下:
curl -XGET 'http://127.0.0.1:9200/geoindex_test/STREET/_search?pretty=1' -d '
{
"query" : {
"match" : { "cityNames.name" : "bridgewater" }
}
}'
我想ElasticSearch將返回第三記錄(id == 3)爲最佳匹配(記錄3與「bridgewater」唯一完全匹配),但是它將id 1(w bridgewater)的記錄返回爲最佳匹配。我究竟做錯了什麼?
如果您在請求中啓用解釋輸出,您可以看到詳細的解釋。只需將'explain = true'請求參數添加到url即可。如果您可以將輸出添加到您的答案,我很樂意爲您提供幫助。 – javanna
@javanna - 謝謝你的回覆。 explain = true的輸出超出了stackoverflow允許的字符數。對不起,我無法提供信息。 –
也許您可以發佈相關部分或使用第三方服務,如pastebin或github主旨。 – javanna