在 ElasticSearch 中,如何查看自定义分析器发出的令牌?

In ElasticSearch how do I see tokens emitted by a custom analyzer?

我正在尝试编写一个带有自己的过滤器和 char_filter 的自定义分析器。如果我能弄清楚如何查看 analyzer/filter/char_filter 组合发出的标记,这将对我有所帮助。

是否有一个 API 查询可用于使用自定义分析器、过滤器和 char_filter 检查从给定字符串发出的标记?

您可以使用此查询来检查为已保存在 elastic 中的给定文档的任何字段发出的标记

curl 'http://localhost:9200/test-idx/_search?pretty=true' -d '{
  "query": {
    "match_all": {},
    "filtered": {
      "filter": {
        "bool": {
          "must": [
            {
              "term": {
                "_id": "1770"
              }
            }
          ]
        }
      }
    }
  },
  "script_fields": {
    "terms": {
      "script": "doc[field].values",
      "params": {
        "field": "input"
      }
    }
  }
}

您还可以使用此工具动态查找任何自定义分析器为字符串发出的标记。

GET autosuggest_index_alllocations1/_analyze?analyzer=index_analyzerV2&text=healthy tiffins