N
N
nepster-web2022-02-04 19:04:16
elasticsearch
nepster-web, 2022-02-04 19:04:16

ElasticSearch 7.17, how to properly search a list of UUIDs?

I create an index (id is uuid):

...
 "mappings": {
    "_field_names": {
      "enabled": true
    },
    "properties": {
      "id": {"type": "keyword"},
        ...
    }
  }
...


I'm uploading data. Further, knowing the uuid list, I need to get data from the elastic.

Request:
{
  "_source": ["id", "city_code", "country_code", "name_en", "name_ru", "name_es", "name_fr", "name_it", "name_de", "name_uk"],
  "query": {
    "terms": {"id" : ["31bbcedb-3ca4-4de6-91b1-62683ec79a4f", "cfd24807-c758-444c-b38c-0a06dbccfe02"]}
  }
}


The result is emptiness. What if you make a request like this:
{
  "_source": ["id", "city_code", "country_code", "name_en", "name_ru", "name_es", "name_fr", "name_it", "name_de", "name_uk"],
  "query": {
    "terms": {"id" : ["31bbcedb", "cfd24807"]}
  }
}


The data will arrive. He doesn't like the "-" character.

How is this treated?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nepster-web, 2022-02-07
@nepster-web

Everything turned out to be simple

"terms": {"id.keyword" : ["31bbcedb-3ca4-4de6-91b1-62683ec79a4f", "cfd24807-c758-444c-b38c-0a06dbccfe02"]}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question