• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


29 Nov, 2024

Updated at 05 Dec, 2024

How to use fields for searching through translations?

Hello,

I have text fields in my database that are translated. I would like to use an analyzer adapted for each language to get the best results.

I thought about using fields like this:

PUT my-index-000001
{
  "mappings": {
    "properties": {
      "text": { 
        "type": "text",
        "fields": {
          "english": { 
            "type":     "text",
            "analyzer": "english"
          },
          "french": { 
            "type":     "text",
            "analyzer": "french"
          }       
        }
      }
    }
  }
}

This way, if an user enters an english or french sentence, I can look up in both fields and will remove the relevant stop words etc.

But I don't understand which kind of payload I should send to create data in that index ? I would think it awaits an object with both french and english key to store each translation, but I receive an error - it awaits text it seems.

Would you please give me an example?

1 post - 1 participant

Read full topic