How can I use stopFilter for english and french words in a unique match query?

Hello,

In my match query,

{
  "query": {
    "match": {
      "message": {
        "query": "Quick foxes",
        "analyzer": "stop"
      }
    }
  }
}

I would like to use a stop filter for English AND french words at the same time. Would you have a recommendation of how I could do it please ?

From Elastic Search to Elasticsearch

Bonjour Yoann.

You need to index the same text twice:

  • French analyzer
  • English analyzer

You can use subfields for that.

Here's an old but still a good source about dealing with multiple languages: Pitfalls of Mixing Languages | Elasticsearch: The Definitive Guide [2.x] | Elastic

HTH

Thank you David for your answer, I'm digging into it.

I thought about creating an analyzer which both language in stop_words to begin with. It could be a little less relevant but much easier to implement:

PUT my-index-000001
{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_english_french_analyzer": {
          "type": "standard",
          "stopwords": ["_english_", "_french_"]
        }
      }
    }
  }
}

Would you have an opinion about it?
Thank you (Merci :smiley: )

This would work but it might give some inaccurate results.
I mean that you probably also need to configure some stemmer and elision filters. If not, your solution would probably work.

1 Like

These subfields are actually quite powerful. Thank you for the advice.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.