ElasticSearch 获取分词的Token

  用ES建好索引,有时候需要获取索引中的Token。ES提供了两个接口,链接如下:

https://www.elastic.co/guide/en/elasticsearch/reference/1.6/docs-termvectors.html#_term_information

https://www.elastic.co/guide/en/elasticsearch/reference/1.6/docs-multi-termvectors.html#docs-multi-termvectors

典型的用法如下,

curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvector?pretty=true'

需要给出索引名,表名,文档id,及关键词_termvector. 但是,本地测试,上述命令是没有结果的,需要指出相关的域.

curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvector?fields=text,...'

这个命令行,还有其他一些选项,如:

curl -XGET 'http://localhost:9200/twitter/tweet/1/_termvector?pretty=true' -d '{
  "fields" : ["text"],
  "offsets" : true,
  "payloads" : true,
  "positions" : true,
  "term_statistics" : true,
  "field_statistics" : true
}'

具体请看文档.

另一个命令差不多,不过是可以可以作用在多个索引上.

原文地址:https://www.cnblogs.com/wmx3ng/p/4635758.html