Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the length and characters in ids generated by elasticsearch?

The documentation of elastic search states:

The index operation can be executed without specifying the id. In such a case, an id will be generated automatically.

But it does not provide any information about the properties of the ids.

  • What is the length (minimun/maximum)?
    my guess is 22.
  • Which characters are used in the id?
    My guess is [-_A-Za-z0-9]
  • Can the properties of the generated ids change at any time (is that part of the API)?
like image 844
Michael_Scharf Avatar asked Nov 08 '13 18:11

Michael_Scharf


People also ask

What is Elasticsearch document id?

Each document has an _id that uniquely identifies it, which is indexed so that documents can be looked up either with the GET API or the ids query. The _id can either be assigned at indexing time, or a unique _id can be generated by Elasticsearch. This field is not configurable in the mappings.

Can Id be a string in Elasticsearch?

Elasticsearch will store the id as a String even if your mapping says otherwise: "mappings": { "properties": { "id": { "type": "integer" }, That is my mapping, but when I do a sort on _id I get documents ordered as: 10489, 10499, 105, 10514...


1 Answers

Auto-generated ids are random base64-encoded UUIDs. The base64 algorithm is used in URL-safe mode hence - and _ characters might be present in ids.

like image 148
imotov Avatar answered Sep 26 '22 02:09

imotov