# Continents, Countries, States and Cities in multiple languages

**URL:** <https://discuss.elastic.co/t/continents-countries-states-and-cities-in-multiple-languages/79185>\
**Category:** Elasticsearch\
**Created:** [March 19, 2017, 7:13pm UTC](https://discuss.elastic.co/t/continents-countries-states-and-cities-in-multiple-languages/79185 "2017-03-19T19:13:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thiagohneves](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiagohneves/32/16491_2.png) [@thiagohneves](https://discuss.elastic.co/u/thiagohneves)\
**Post date:** [March 19, 2017, 7:13pm UTC](https://discuss.elastic.co/t/continents-countries-states-and-cities-in-multiple-languages/79185/1 "2017-03-19T19:13:48Z")

</div>

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!!!!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 19, 2017, 10:03pm UTC](https://discuss.elastic.co/t/continents-countries-states-and-cities-in-multiple-languages/79185/2 "2017-03-19T22:03:36Z")

</div>

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

- I'd not use any wildcard. It's not the best thing to do. I'd use a edge n gram strategy at index time and a simple analyzer at search time. [https://www.elastic.co/guide/en/elasticsearch/guide/2.x/\_ngrams\_for\_partial\_matching.html](https://www.elastic.co/guide/en/elasticsearch/guide/2.x/_ngrams_for_partial_matching.html)
- No need to use function score here. You can have a single document which contains all names in all languages like `name_en`, `name_fr`, `name_de`... Then search with a match query in those fields and boost the result depending on what you want to do.
- Have a look a suggest API. Might be a much better fit for your use case: [https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-suggesters.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-suggesters.html). Specifically this one: [https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-suggesters-completion.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-suggesters-completion.html)

I hope this helps.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 16, 2017, 10:03pm UTC](https://discuss.elastic.co/t/continents-countries-states-and-cities-in-multiple-languages/79185/3 "2017-04-16T22:03:53Z")

</div>

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