es前缀模糊匹配自定义edge_ngram

  • edge_ngram 自定义analyzer, 针对英文编码字符串,大写转小写filter,前10位切割,不分词
put /my_index
{
    "settings": {
        "analysis": {
            "analyzer": {
                "code_index_analyzer": {
                    "tokenizer": "code_index_tokenizer",
                    "filter": [
                        "lowercase"
                    ]
                },
                "code_search_analyzer": {
                    "tokenizer": "keyword",
                    "filter": [
                        "lowercase"
                    ]
                }
            },
            "tokenizer": {
                "code_index_tokenizer": {
                    "type": "edge_ngram",
                    "min_gram": 1,
                    "max_gram": 10
                }
            }
        }
    }
}
  • mapping字段设置
PUT /my_index/my_type/_mappings
{
    "my_type": {
        "properties": {
            "name": {
                "type":            "text",
                "analyzer":  "code_index_analyzer", 
                "search_analyzer": "code_search_analyzer" 
            }
        }
    }
}
  • 索引别名
    https://www.elastic.co/guide/cn/elasticsearch/guide/current/index-aliases.html

你可能感兴趣的:(es前缀模糊匹配自定义edge_ngram)