🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# index_options(索引设置) **index_options** 参数用于控制添加到倒排索引中的信息,服务于搜索和高亮等目的。他可以包括以下参数: **docs**: 只有文档编号被索引。能够回答的问题只有此 **term**(词条)是否存在于此字段。 **freqs**:文档编号和 **term**(词条)的频率会被索引。**term**(词条)频率用于给搜索评分,重复出现的 **term**(词条)评分将高于单个出现的  **term**(词条)。 **positions**:文档编号、**term frequencies**(词条频率)和**term**(词条)位置(或顺序)将被索引。**Position**被用于 **[proximity](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/query-dsl-match-query-phrase.html "Match Phrase Query") queries **(邻近查询)和** [phrase queries](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/query-dsl-match-query-phrase.html "Match Phrase Query")**(短语查询)。 **offsets**: 文档编号、**term**(词条)频率,位置,起始和结尾字符偏移量(用于映射该 **term **(词条)到原始字符串)将被索引。**Offset**用于**[postings highlighter](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/search-request-highlighting.html#postings-highlighter "Postings highlighter")**。 被分析器分析的字符串字段使用 **position **作为默认值,其他的字段使用 **docs **作为默认值。 | `curl -XPUT ``'localhost:9200/my_index?pretty'` `-H ``'Content-Type: application/json'` `-d'` `{` `"mappings"``: {` `"my_type"``: {` `"properties"``: {` `"text"``: {` `"type"``: ``"text"``,` `"index_options"``: ``"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 |  **text** 字段将使用**postings highlighter** 作为默认值,因为他的索引配置为 **offsets**。 |