javad helali
javad helali

Reputation: 270

Custom predefined stopword list in Elasticsearch

How can i define a custom stopword list globally in a way it is accessible from all indexes.

it would be ideal to use this stopword list just like the way we use predefined language-specific stopword lists:

PUT /my_index
{
    "settings": {
        "analysis": {
            "filter": {
                "my_stop": {
                    "type":       "stop",
                    "stopwords":  "_my_predefined_stopword_list_"
                }
            }
        }
    }
}

Upvotes: 0

Views: 903

Answers (1)

paweloque
paweloque

Reputation: 18864

The official elastcisearch documentation describes how to create a custom filter with a list of stopwords. You can find the description here:

https://www.elastic.co/guide/en/elasticsearch/guide/current/using-stopwords.html

PUT /my_index
{
  "settings": {
    "analysis": {
      "filter": {
        "spanish_stop": {
          "type":        "stop",
          "stopwords": [ "si", "esta", "el", "la" ]  
        },
        "light_spanish": { 
          "type":     "stemmer",
          "language": "light_spanish"
        }
      },
      "analyzer": {
        "my_spanish": {
          "tokenizer": "spanish",
          "filter": [ 
            "lowercase",
            "asciifolding",
            "spanish_stop",
            "light_spanish"
          ]
        }
      }
    }
  }
}

After defining this filter spanish_stop you can use it in the definition of your indices.

Upvotes: 1

Related Questions