欢迎投稿

今日深度:

Elasticsearch,

Elasticsearch,


现代搜索离不开自动补全功能。正是有了该功能,用户可以方便地找到那些不知如何拼写的条目。

看如下索引配置:

{
"settings": {
    "analysis": {
         "analyzer": {
             "standardWithEdgeNGram": {
                 "tokenizer": "standard",
                 "filter": ["lowercase", "edgeNGram"]
             }
         },
         "tokenizer": {
             "standard": {
                 "type": "standard"
             }
         },
         "filter": {
             "lowercase": {
                "type": "lowercase"
            },
            "edgeNGram": {
                "type": "edgeNGram",
                "min_gram": 2,
                "max_gram": 15,
                "token_chars": ["letter", "digit"]

            }
        }
    }
},
"mappings": {
    "test": {
        "_all": {
            "analyzer": "standardWithEdgeNGram"
        },
        "properties": {
            "Name": {
                "type": "string",
                "index_analyzer": "standardWithEdgeNGram"
               "index": "analyzed","search_analyzer":"standard"
            }        
}   
}
}
}

min_gram:长度小于此参数值的词条将不会被生成。这个值直接影响了进行提示所需的最小字符个数。

max_gram:分词器会忽略长度超过此参数值的词条。这是可用提示的最大字符个数。我们假设越长的查询越不需要提示,因为用户很可能已经知道了自己想要的查询目标了。


www.htsjk.Com true http://www.htsjk.com/Elasticsearch/35409.html NewsArticle Elasticsearch, 现代搜索离不开自动补全功能。正是有了该功能,用户可以方便地找到那些不知如何拼写的条目。 看如下索引配置: { "settings": {     "analysis": {          "analyzer": {    ...
相关文章
    暂无相关文章
评论暂时关闭