加载中

Token count 字段类型

token_count 类型的字段实际上是一个 integer 字段,它接受字符串值,对其进行分析,然后索引字符串中的 token 数量。

例如

				PUT my-index-000001
					{
  "mappings": {
    "properties": {
      "name": {
        "type": "text",
        "fields": {
          "length": {
            "type":     "token_count",
            "analyzer": "standard"
          }
        }
      }
    }
  }
}
				PUT my-index-000001/_doc/1
					{ "name": "John Smith" }
				PUT my-index-000001/_doc/2
					{ "name": "Rachel Alice Williams" }
				GET my-index-000001/_search
					{
  "query": {
    "term": {
      "name.length": 3
    }
  }
}
		
  1. name 字段是一个使用默认 standard 分析器的 text 字段。
  2. name.length 字段是一个 token_count 多字段,它将索引 name 字段中的 token 数量。
  3. 此查询仅匹配包含 Rachel Alice Williams 的文档,因为它包含三个 token。

token_count 字段接受以下参数

analyzer
应该用于分析字符串值的 analyzer。必需项。为了获得最佳性能,请使用不包含 token 过滤器的分析器。
enable_position_increments
指示是否应计算位置增量。如果不希望计算被分析器过滤器(例如 stop)移除的 token,请将其设置为 false。默认值为 true
doc_values
是否应以列跨度(column-stride)方式将字段存储在磁盘上,以便以后用于排序、聚合或脚本编写?接受 true(默认)或 false
index
该字段是否可搜索?接受 true(默认)和 false
null_value
接受一个与该字段具有相同 type 的数值,用于替代任何显式的 null 值。默认为 null,这意味着该字段将被视为缺失。
store
是否应将字段值存储并可从 _source 字段中独立检索。接受 truefalse(默认)。

token_count 字段在其默认配置中支持 合成 _source

© . 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.