> For the complete documentation index, see [llms.txt](https://xiaoxiami.gitbook.io/elasticsearch/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://xiaoxiami.gitbook.io/elasticsearch/ji-chu/mapping/323mapping-parametersff08-ying-she-can-shu-ff09/indexoptions-ff08-suo-yin-she-zhi-ff09.md).

# 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) **queries** （邻近查询）和[**phrase queries**](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/query-dsl-match-query-phrase.html)（短语查询）。

**offsets**： 文档编号、**term**（词条）频率,位置,起始和结尾字符偏移量（用于映射该 **term** （词条）到原始字符串）将被索引。**Offset**用于[**postings highlighter**](https://www.elastic.co/guide/en/elasticsearch/reference/5.3/search-request-highlighting.html#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**。 |
| - | ------------------------------------------------------------------- |
