【问题标题】:Find most similar documents in Elasticsearch在 Elasticsearch 中查找最相似的文档
【发布时间】:2019-08-27 20:24:20
【问题描述】:

如何在 Elasticsearch 中的两个索引之间找到前 100 个最相似的文档?

文档 #1 位于 index1、type11、field111 中。 文档 #2 在 index2、type21、field211 中

编辑:两个字段都是字符串。

我查看了More Like This query 的文档。但它并没有告诉我如何快速比较不同类型相似性指标的结果并查看最佳结果。

【问题讨论】:

  • field111和field211有哪些类型?
  • 哦..都是字符串。
  • 您能否提供您所指的两个文档的 ID?
  • 最初的目的是寻找最相似文档对的 ID。这在 Elasticsearch 中是不可能的吗?我知道循环遍历文档对仍然是可能的……但不是我想要的。

标签: elasticsearch nlp sentence-similarity


【解决方案1】:

试试这个查询,但是用 id 值代替你的文档:

GET index1,index2/_search
{
  "query": {
    "more_like_this": {
      "fields": [
        "field111",
        "field211"
      ],
      "like": [
        {
          "_index": "index1",
          "_id": "DOC_1_ID"
        },
        {
          "_index": "index2",
          "_id": "DOC_2_ID"
        }
      ],
      "min_term_freq": 1,
      "max_query_terms": 12
    }
  }
}

【讨论】:

  • 如何使用多个相似性度量?这是默认的 tf-idf 指标吗?
  • 今天在弹性博客上:elastic.co/blog/…
猜你喜欢
  • 2016-07-07
  • 2014-06-09
  • 2013-12-22
  • 1970-01-01
  • 1970-01-01
  • 2012-03-17
  • 1970-01-01
  • 2012-08-20
  • 1970-01-01
相关资源
最近更新 更多