从弹性搜索中得不到术语向量?

时间:2016-11-23 16:46:05

标签: elasticsearch kibana

enter image description here

我正在关注https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-termvectors.html,但无法获得预期的结果。哪个部分我做错了?

文件格式为:

PUT integrity
{
  "mappings": {
    "body": {
      "properties": {
        "label": {
          "type": "keyword",
          "index": "not_analyzed",
          "store": true
        },
        "body": {
          "type": "text",
          "store": true
        }
      }
    }
  }
}

1 个答案:

答案 0 :(得分:0)

_all字段的默认映射不包括存储术语向量:

    "_all": {
      "full_name": "_all",
      "mapping": {
        "_all": {
          "enabled": true,
          "store": false,
          "store_term_vectors": false,
          "store_term_vector_offsets": false,
          "store_term_vector_positions": false,
          "store_term_vector_payloads": false,
          "norms": true,
          "analyzer": "default",
          "similarity": "BM25"
        }
      }
    }

而且,似乎_all字段有点特殊而且Elasticsearch没有compute the vectors on the fly

_all的唯一选择是在其上启用术语向量:

PUT integrity
{
  "mappings": {
    "body": {
      "_all": {
        "term_vector": "with_positions_offsets"
      }, 
      "properties": {
        "label": {
          "type": "keyword",
          "index": "not_analyzed",
          "store": true
        },
        "body": {
          "type": "text",
          "store": true
        }
      }
    }
  }
}