0
0
Elasticsearchquery~30 mins

Numeric field types in Elasticsearch - Mini Project: Build & Apply

Choose your learning style9 modes available
Numeric Field Types in Elasticsearch
📖 Scenario: You are setting up an Elasticsearch index to store product information. Each product has a price and a quantity in stock. You want to use the correct numeric field types to store these values efficiently and correctly.
🎯 Goal: Create an Elasticsearch index mapping that defines numeric fields for price and quantity. Then add a document with sample values and retrieve it to see the stored data.
📋 What You'll Learn
Create an index mapping with price as a float field
Create an index mapping with quantity as an integer field
Index a sample document with price 19.99 and quantity 100
Retrieve and print the stored document
💡 Why This Matters
🌍 Real World
Numeric fields in Elasticsearch are used to store numbers like prices, quantities, and IDs efficiently. Choosing the right numeric type helps with performance and storage.
💼 Career
Understanding numeric field types is important for roles like data engineers, backend developers, and search specialists who design and maintain Elasticsearch indexes.
Progress0 / 4 steps
1
Create the index mapping with numeric fields
Create an index mapping called products with a properties object that defines price as a float field and quantity as an integer field.
Elasticsearch
Need a hint?

Use "type": "float" for price and "type": "integer" for quantity inside properties.

2
Add a sample document to the index
Create a JSON document with price set to 19.99 and quantity set to 100 to index into the products index.
Elasticsearch
Need a hint?

Set "price" to 19.99 and "quantity" to 100 in the document.

3
Index the document using Elasticsearch API
Use the Elasticsearch index API to add the document with price 19.99 and quantity 100 to the products index.
Elasticsearch
Need a hint?

Use PUT /products to create the index and PUT /products/_doc/1 to add the document.

4
Retrieve and print the stored document
Use the Elasticsearch GET API to retrieve the document with ID 1 from the products index and print the _source field showing price and quantity.
Elasticsearch
Need a hint?

Use GET /products/_doc/1 to retrieve the document and check the _source field.