How do I enable stemming in Elasticsearch?

elasticsearch, lucene

Solution

The most generic way to do it is by replacing `default` analyzer with `snowball` analyzer. This will enable stemming for all dynamically-mapped string fields. This is how you can enable english stemmer:

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"
                }
            }
        }
    }
}'

Problem

``` curl -XPUT "localhost:9200/products" -d '{ "settings": { "index": { "number_of_replicas" : 0, "number_of_shards": 1 } }, "mappings": { "products": { "properties": { "location" : { "type" : "geo_point" } } } } }' ``` I currently have a bash script that creates my index. Code is above. How do I add stemming to it?

Original source