Elasticsearch - similary for countries

限于喜欢 提交于 2019-12-11 06:59:35

问题


I have a document, which contains many fields, one of them is country. There are many documents with the same country.

When I do match query, or fuzzy search against country, and query for Belgium for example, it returns list of documents, which matched Belgium country, but they all have different score. I believe it's because of tdidf similarity and presence of belgium term in other fields of documents, etc.

I'd like it return the same score in this case. What similarity should I use?

Update

I have next 6 documents:

{country:"Austria", title: "house"}
{country:"Austria", title: "Austria village"}
{country: "Germany", title: "deutch hotel" }
{country:"Austria", title: ""}
{country: "USA", title: "Usa hotel" }
{country: "USA", title: "Usa another hotel" }

When I execute match query against country:

{
   query: {match: {country: "Austria"}}
}

I reveice next results:

[ {
  "_index" : "elasticdemo_docs",
  "_type" : "doc",
  "_id" : "1",
  "_score" : 1.0, "_source" : {country:"Austria", title: "Austria village"}
}, {
  "_index" : "elasticdemo_docs",
  "_type" : "doc",
  "_id" : "2",
  "_score" : 0.30685282, "_source" : {country:"Austria", title: "house"}
}, {
  "_index" : "elasticdemo_docs",
  "_type" : "doc",
  "_id" : "3",
  "_score" : 0.30685282, "_source" : {country:"Austria", title: ""}
} ]

I'd like to receive the same _score for all 3 documents, because they all have Austria as a country. What similarity should I use?


回答1:


Seems I found the problem - it's connected with: http://www.elasticsearch.org/blog/understanding-query-then-fetch-vs-dfs-query-then-fetch/

After using dfs_query_then_fetch search type I've got expected results.



来源:https://stackoverflow.com/questions/22016735/elasticsearch-similary-for-countries

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!