简体   繁体   中英

Elasticsearch mapping integer or long

I am using ES for my laravel app as an search engine.

But when it comes to mapping i am not sure whenever to use integer or long for my numbers?

I have a MySql DB that adds data live to my ES database.

I need to make my numbers searchable or sortable. Eg sort by price or search by price.

I cant find anything in the docs saying when to use integer or long.

Thanks in advance

The only difference between int and long is the size of the number that can be represented. Basically, int is a 32 bit signed integer, and long is a 64 bit signed integer. So, if the value you need to represent is larger than 2 31 - 1, then you need to use a long.

To ensure that you can search/sort by your field, you need to make sure that it is indexed (not_analyzed).

Elasticserach mapping documentation.
Elasticsearch core types documentation.
Java primitive types documentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM