加载中

index_options

index_options 参数用于控制将哪些信息添加到倒排索引中,以便进行搜索和高亮显示。只有基于词项的字段类型(例如 textkeyword)支持此配置。

注意

semantic_text 字段类型也使用 index_options 参数。不过,在这种情况下,该参数配置的是底层向量索引设置(例如量化或词元修剪),而非标准的文本索引功能。请参阅 semantic text 文档,以为稀疏向量稠密向量配置 index_options

该参数接受以下值之一。每个值都包含前面所列出的值的信息。例如,freqs 包含 docspositions 同时包含 freqsdocs

文档 (docs)
仅索引文档编号。可以回答诸如“此字段中是否存在该词项?”之类的问题。
freqs
索引文档编号和词项频率。词项频率用于对重复词项赋予比单个词项更高的评分。
positions(默认)
索引文档编号、词项频率和词项位置(或顺序)。位置可用于邻近查询或短语查询
offsets
索引文档编号、词项频率、位置以及字符的开始和结束偏移量(将词项映射回原始字符串)。偏移量被统一高亮显示器用于加速高亮显示。
				PUT my-index-000001
					{
  "mappings": {
    "properties": {
      "text": {
        "type": "text",
        "index_options": "offsets"
      }
    }
  }
}
				PUT my-index-000001/_doc/1
					{
  "text": "Quick brown fox"
}
				GET my-index-000001/_search
					{
  "query": {
    "match": {
      "text": "brown fox"
    }
  },
  "highlight": {
    "fields": {
      "text": {}
    }
  }
}
		
  1. 默认情况下,由于已索引 offsetstext 字段将使用 postings 进行高亮显示。
© . This website operates independently and is not affiliated with or endorsed by Elasticsearch B.V. All brand names, logos, and trademarks are the property of their respective owners.