Continents, Countries, States and Cities in multiple languages

Hi guys, how are you?

I'm new in Elasticsearch and I do need to developer a feature that has an unique input form that searches many documents. I create one language per document, ex:

continents-en, continents-pt-br, countries-en, countries-pt-br, cities-en, cities-pt-br

Each document has specifics attributes (id, code, name, lat, long...), ex:

continents-en
1, SA, North America

countries-en
1, US, United States
2, BR, Brazil

countries-pt-br
1, US, Estados Unidos
2, BR, Brasil

cities-en
1, New York, Lat, Long...

cities-pt-br
1, Nova Iorque, Lat, Long...

First question: Is that the best way to do that?

So, i created this elasticsearch search:

curl -XGET 'http://localhost:9000/countries-*,continents-*,cities-*/_search' -d '
{
  "size": 20,
  
  "query": {

    "function_score": {
      "query": {
        "wildcard": { "name": "#{query}*" }
      },
      "functions": [
        {
          "filter": { "term": { "_type": "continent" }},
          "weight": 10000
        },
        {
          "filter": { "term": { "_type": "country" }},
          "weight": 8000
        },
        {
          "filter": { "term": { "_type": "city" }},
          "weight": 6000
        }
      ]
    }
  }
}'

The problem is when i type "bra" on the input form, i receive the result: Brazil and Brasil. The mainly language is Portuguese so if i have a Portuguese translation i'd like to ignore the English translation because the results has the same country id.

How can i do that?

Thank you so much!!!!

Some comments (sorry to not answering directly your question yet):

I hope this helps.

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