1. Term_vectors(词根信息)
Term vectors 是通过分析器解析产生的信息,包括:
- 一组 terms (词根)。
- 每个词根的位置(顺序)。
- 映射词根的首字符和尾字符与原始字符串原点的偏移量。
这些 term vectors 将被存储,一遍将他从一个特定的文档中取出。
term_vector 有一下参数设置:
| no | 不存储 term vectors 信息。(默认值) | | yes | 仅次字段中的 terms(词根)被存储。 | | with_positions | 存储词根和位置。 | | with_offset | 存储词根和字符偏移量。 | | with_positions_offsets | 存储词根、位置和字符偏移量。 |
fast vector highlighter 需要用到 with_positions_offsets。term vectors API 可以检索存储的任何内容。
警告
使用 with_positions_offsets 将会是字段的索引大小增加一倍。
curl -XPUT 'localhost:9200/my_index?pretty' -H 'Content-Type: application/json' -d'
{
"mappings": {
"my_type": {
"properties": {
"text": {
"type": "text",
"term_vector": "with_positions_offsets"
}
}
}
}
}
'
curl -XPUT 'localhost:9200/my_index/my_type/1?pretty' -H 'Content-Type: application/json' -d'
{
"text": "Quick brown fox"
}
'
curl -XGET 'localhost:9200/my_index/_search?pretty' -H 'Content-Type: application/json' -d'
{
"query": {
"match": {
"text": "brown fox"
}
},
"highlight": {
"fields": {
"text": {} #1
}
}
}
'
| 1 | 因为 term vectors 功能的使用,text 字段将会默认使用 fast vector highlighter。 |
原文链接 : https://www.elastic.co/guide/en/elasticsearch/reference/5.3/term-vector.html(修改该链接为官网对应的链接)
译文链接 : http://www.apache.wiki/pages/viewpage.action?pageId=10027731(修改该链接为 ApacheCN 对应的译文链接)