elasticsearch query_string术语在术语向量中但不匹配

时间:2017-09-12 22:41:30

标签: elasticsearch

无法获取query_string查询以匹配我的文档。运行一个非常简单的查询,我希望根据这些条款匹配。我已经包含了我期望匹配的文档的_termvector查询的相关输出。以及我正在尝试的示例的解释查询。

GET site/site_doc/dcb2ae16-da4e-11e5-94d8-0ac67484b577/_termvectors?fields=name,extras,amenities

{
  "_index": "site",
  "_type": "site_doc",
  "_id": "dcb2ae16-da4e-11e5-94d8-0ac67484b577",
  "_version": 2,
  "found": true,
  "took": 0,
  "term_vectors": {
    "extras": {
      "field_statistics": {
        "sum_doc_freq": 30,
        "doc_count": 10,
        "sum_ttf": 37
      },
      "terms": {
        "bullet": {
          "term_freq": 1,
          "tokens": [
            {
              "position": 101,
              "start_offset": 5,
              "end_offset": 12
            }
          ]
        },
        "gun": {
          "term_freq": 1,
          "tokens": [
            {
              "position": 0,
              "start_offset": 0,
              "end_offset": 4
            }
          ]
        }
      }
    },
   ...
}

解释的输出

GET site/site_doc/dcb2ae16-da4e-11e5-94d8-0ac67484b577/_explain
{
  "query": {
    "query_string": {
      "query": "gun"
    }
  }
}

{
  "_index": "site",
  "_type": "site_doc",
  "_id": "dcb2ae16-da4e-11e5-94d8-0ac67484b577",
  "matched": false,
  "explanation": {
    "value": 0,
    "description": "no matching term",
    "details": []
  }
}

我必须明确设置

query.querystring.fields=['extras', 'amenities']

在这些字段中查找字词。我不确定为什么或如何使它工作,所以如果有人想解释或指向文档,我不会回答我自己的问题。

这是索引的映射

{
  "site": {
    "mappings": {
      "site_doc": {
        "properties": {
          "amenities": {
            "type": "text",
            "analyzer": "snowball"
          },
          "extras": {
            "type": "text",
            "analyzer": "snowball"
          },
          "headline": {
            "type": "text"
          },
          "name": {
            "type": "text",
            "analyzer": "snowball"
          }
        }
      }
    }
  }
}

0 个答案:

没有答案