1、term vector介绍
获取document中的某个field内的各个term的统计信息
term information: term frequency in the field, term positions,start and end offsets, term payloads
term statistics: 设置term_statistics=true; total term frequency, 一个term在所有document出现的频率,document frequency, 有多少document包含这个term
field statistics: document count, 有多少document包含这个field; sum of document frequency, 一个field中所有term的df之和; sum of total term frequency, 一个field中的所有term的tf之和
GET /twitter/tweet/1/_termvector
GET /twitter/tweet/1/_termvector?fields=text
term statistics 和 field statistics并不精准, 不会考虑有的doc可能被删除了
用的时候,一般来说,就是你需要对一些数据做探查的时候。比如说,你想要看到某个term,某个词条,大话西游,这个词条,在多少个document中出现了。或者说某个field,film_desc,电影的说明信息,有多少个doc包含了这个说明信息。
2、index-tiem term vector实验
term vector, 涉及了很多的term和field相关的统计信息,有两种方式可以采集到这个统计信息
(1) index-time, 你在mapping里配置一下,然后建立索引的时候,就直接给你生成这些term和field的统计信息了
(2) query-time, 你之前没有生成过任何的Term vector信息, 然后在查看term vector的时候, 直接就可以看到了, 会on the fly, 现场计算出各种统计信息, 然后返回给你
PUT /my_index
{
"mappings": {
"my_type": {
"properties": {
"text": {
"type": "text",
"term_vector": "with_positions_offsets_payloads",
"store": true,
"analyzer": "fulltext_analyzer"
},
"fullname": {
"type": "text",
"analyzer": "fulltext_analyzer"
}
}
}
},
"settings": {
"index": {
"number_of_shards":