弹性搜索 - 类似于国家 [英] Elasticsearch - similary for countries

查看:169
本文介绍了弹性搜索 - 类似于国家的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文档,其中包含许多字段,其中之一是 country 。有许多文件具有相同的国家

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

当我执行匹配查询 fuzzy 搜索 country ,并查询比利时例如,它返回与比利时国家匹配的文档列表,但它们都有不同的分数。我相信这是因为tdidf的相似性和在其他文档领域等的 belgium 术语的存在。

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.

在这种情况下,d喜欢返回相同的分数。我应该使用什么相似之处?

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

更新

我有下6个文件:

{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"}}
}

我尊重下一个结果:

[ {
  "_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: ""}
} ]

喜欢为所有3个文档收到相同的 _score ,因为他们都有奥地利作为一个国家。我应该使用什么相似之处?

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?

推荐答案

似乎我发现这个问题 - 与...有关:
http://www.elasticsearch.org/blog/understanding -query-then-fetch-vs-dfs-query-then-fetch /

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

使用 dfs_query_then_fetch 搜索类型我有预期的结果。

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

这篇关于弹性搜索 - 类似于国家的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆