如何查看已编制索引的分析数据?

时间:2017-04-14 16:02:54

标签: elasticsearch

如何在索引内容后看到存储的分析数据。

我知道你可以像这样进行搜索

http://localhost:9200/local_products_fr/fields/_search/

但我想看到的是实际数据而不是_source

类似于调用_analyzer

时得到的内容
http://localhost:9200/local_products_fr/_analyze?text=<p>my <b>super</b> text</p>&analyzer=analyzer_fr

{
  "tokens": [
    {
      "token": "my",
      "start_offset": 3,
      "end_offset": 5,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "b",
      "start_offset": 7,
      "end_offset": 8,
      "type": "<ALPHANUM>",
      "position": 1
    },
    {
      "token": "sup",
      "start_offset": 9,
      "end_offset": 14,
      "type": "<ALPHANUM>",
      "position": 2
    },
    {
      "token": "b",
      "start_offset": 16,
      "end_offset": 17,
      "type": "<ALPHANUM>",
      "position": 3
    },
    {
      "token": "text",
      "start_offset": 19,
      "end_offset": 23,
      "type": "<ALPHANUM>",
      "position": 4
    }
  ]
}

1 个答案:

答案 0 :(得分:2)

我使用它来获取每个文档的字段的反向索引

{
    "query": {
        "bool": {
            "must": [{
                "term": {
                    "_id": {
                        "value": "2"
                    }
                }
            }]
        }
    },
    "script_fields": {
        "terms": {
            "script": "doc['product.name'].values"
        }
    }
}

希望这适合你