【问题标题】:Elasticsearch: How to store term vectorsElasticsearch:如何存储术语向量
【发布时间】:2016-11-10 23:15:09
【问题描述】:

我正在开展一个项目,我大量使用 Elasticsearch 并利用 moreLikeThis 查询来实现一些功能。 MLT 查询的官方文档说明如下:

为了加快分析速度,将术语向量存储在 索引时间,但以磁盘使用为代价。

在**工作原理*部分。现在的想法是调整映射以存储预先计算的术语向量。问题是,从文档中似乎不清楚应该如何做到这一点。一方面,在MLT 文档中,他们提供了如下所示的示例映射:

curl -s -XPUT 'http://localhost:9200/imdb/' -d '{
  "mappings": {
    "movies": {
      "properties": {
        "title": {
          "type": "string",
          "term_vector": "yes"
         },
         "description": {
          "type": "string"
        },
        "tags": {
          "type": "string",
          "fields" : {
            "raw": {
              "type" : "string",
              "index" : "not_analyzed",
              "term_vector" : "yes"
            }
          }
        }
      }
    }
  }
}

另一方面,在 Term Vectors documentation 中,它们在 示例 1 部分中提供了一个如下所示的映射

curl -s -XPUT 'http://localhost:9200/twitter/' -d '{
  "mappings": {
    "tweet": {
      "properties": {
        "text": {
          "type": "string",
          "term_vector": "with_positions_offsets_payloads",
          "store" : true,
          "index_analyzer" : "fulltext_analyzer"
         },
         "fullname": {
          "type": "string",
          "term_vector": "with_positions_offsets_payloads",
          "index_analyzer" : "fulltext_analyzer"
        }
      }
    }
    ....

这应该是create an index that stores term vectors, payloads etc.

现在的问题是:应该使用哪个映射?这是文档中的缺陷还是我遗漏了什么?

【问题讨论】:

  • 第二个例子也只是存储额外的信息。我想这对你来说应该足够了,只需使用“是”
  • 但是这种行为是否以某种方式记录在某处?就像“yes”做一些事情而“with_positions_offsets_payloads”做更多?

标签: elasticsearch morelikethis


【解决方案1】:

您说得对,当前版本的文档中似乎没有明确提及,但在即将发布的 2.0 documents 中有更详细的解释。

术语向量包含有关由 分析过程,包括:

  • 术语列表。
  • 每个术语的位置(或顺序)。
  • 将术语映射到其在原始字符串中的原点的开始和结束字符偏移量。

可以存储这些术语向量,以便检索它们 特定文件。

term_vector 设置接受:

  • no:没有存储术语向量。 (默认)
  • yes:只存储字段中的术语
  • with_positions:已存储条款和职位
  • with_offsets:存储术语和字符偏移量
  • with_positions_offsets:存储术语、位置和字符偏移量

【讨论】:

  • 太好了,谢谢 :) 我只是希望 2.0 文档也适用于以前的版本,但是从我所做的一些测试来看,看起来确实如此
猜你喜欢
  • 1970-01-01
  • 2014-02-10
  • 2020-10-25
  • 2016-07-18
  • 2018-04-26
  • 1970-01-01
  • 1970-01-01
  • 2016-06-26
  • 1970-01-01
相关资源
最近更新 更多