如何在Elasticsearch中启用词干分析?

TIM*_*MEX 3 lucene elasticsearch

curl -XPUT "localhost:9200/products" -d '{
    "settings": {
        "index": {
            "number_of_replicas" : 0,
            "number_of_shards": 1
        }
    },
    "mappings": {
        "products": {
            "properties": {
                "location" : {
                    "type" : "geo_point"
                }
            }
        }
    }
}'
Run Code Online (Sandbox Code Playgroud)

我目前有一个创建索引的bash脚本.代码在上面.

如何添加词干?

imo*_*tov 6

最通用的方法是用default分析snowball仪替换分析仪.这将启用所有动态映射的字符串字段.这是你如何启用英语词干分析器:

curl -XPUT "localhost:9200/products" -d '{
    "settings": {
        "index": {
            "number_of_replicas" : 0,
            "number_of_shards": 1,
            "analysis" :{
                "analyzer": {
                    "default": {
                        "type" : "snowball",
                        "language" : "English"
                    }
                }
            }  
        }
    },
    "mappings": {
        "products": {
            "properties": {
                "location" : {
                    "type" : "geo_point"
                }
            }
        }
    }
}'
Run Code Online (Sandbox Code Playgroud)

  • 映射有什么用?这与它有什么关系吗? (2认同)