Let's say I have an index of News with many documents of different langages. Users have one search bar to look for the title they desire among the different langages. I don't know which langage the user is typing so I would like to remove stopwords depending on the document langage.
This is how I tried to define my index:
{
name: "news",
mappings: {
dynamic: false,
properties: {
id: { type: "keyword" },
title: { type: "text" },
content: { type: "text" },
lang: { type: "keyword" },
created_at: { type: "date" },
updated_at: { type: "date" },
},
},
settings: {
analysis: {
analyzer: {
default: {
type: "custom",
tokenizer: "standard",
filter: ["my_custom_stop_words_filter"],
},
},
filter: {
my_custom_stop_words_filter: {
type: "stop",
stopwords: "_english_",
script: {
source: "lang.getText() === 'english'",
},
},
},
},
}
I want to be able to filter out the right stopwords for every documents depending on the field "lang" of each document. How can I achieve this ?