前缀索引(Index Prefixes)

前缀索引(Index Prefixes) #

启用前缀查询的优化。当启用此参数时,Easysearch 会为前缀查询构建额外的索引结构。

基本用法 #

PUT my-index
{
  "mappings": {
    "properties": {
      "username": {
        "type": "text",
        "index_prefixes": {}
      }
    }
  }
}

适用的字段类型 #

  • text
  • match_only_text

参数选项 #

{
  "min_chars": 0,
  "max_chars": 20
}
  • min_chars: 最小前缀长度(默认值:0)
  • max_chars: 最大前缀长度(默认值:20)

说明 #

启用 index_prefixes 后,通配符查询和前缀查询的性能会显著提高。但会增加索引大小。较小的 min_charsmax_chars 值会使索引更大。

相关参数 #