Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch document id type integer vs string : Is there any performace difference?

I am using elasticsearch 2.3.1. Currently all the document ids are integer. But I have a situation where the document ids can be numeric valued or sometimes alpha-numeric string. So I need to make the field type 'string'.

So, I need to know if there is any performance difference based on the type of Id. Please help....

like image 382
Devasish Avatar asked Apr 13 '16 11:04

Devasish


1 Answers

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

i.e. in String order.

like image 91
Kong Avatar answered Nov 09 '22 03:11

Kong