What if your price searches could be instant and always correct, without extra work?
Why Numeric field types in Elasticsearch? - Purpose & Use Cases
Imagine you have a huge list of product prices stored as plain text in your search database. You want to find all products cheaper than $50, but since prices are text, you have to manually convert and compare each one every time.
This manual way is slow because every search needs extra steps to convert text to numbers. It's also error-prone since text sorting treats '100' as less than '50'. This causes wrong search results and wastes time.
Using numeric field types in Elasticsearch means prices are stored as real numbers. Elasticsearch can quickly compare, sort, and filter these values without extra work. This makes searches fast, accurate, and easy.
GET /products/_search
{
"query": {
"range": {
"price": {
"lt": "50"
}
}
}
}PUT /products
{
"mappings": {
"properties": {
"price": { "type": "float" }
}
}
}
GET /products/_search
{
"query": {
"range": {
"price": {
"lt": 50
}
}
}
}It enables lightning-fast and precise numeric searches, filters, and sorting on your data.
Online stores use numeric field types to quickly find products under a certain price or within a price range, giving shoppers instant results.
Storing numbers as text causes slow and wrong searches.
Numeric field types store real numbers for fast, accurate queries.
This improves search speed and result quality in Elasticsearch.