Elasticsearch Cheat Sheet
Elasticsearch REST API essentials for indexing, searching, filtering, and aggregating documents with mappings and analyzers.
2 PagesIntermediateMar 15, 2026
REST API Basics
Creating an index and indexing documents.
bash
# Create an index with an explicit mappingPUT /products{ "mappings": { "properties": { "name": { "type": "text" }, "price": { "type": "float" } } }}# Index a documentPOST /products/_doc/1{ "name": "Laptop", "price": 999.99 }# Get and deleteGET /products/_doc/1DELETE /products
Search Queries
Bool queries, filters, and sorting.
bash
GET /products/_search{ "query": { "bool": { "must": [{ "match": { "name": "laptop" } }], "filter": [{ "range": { "price": { "lte": 1500 } } }] } }, "sort": [{ "price": "asc" }], "size": 10}# Simple query string searchGET /products/_search?q=name:laptop
Core Concepts
Building blocks of the search engine.
- Index- a collection of documents, roughly analogous to a database table
- Shard- a horizontal partition of an index, enabling scale-out
- Replica- a copy of a shard for high availability and extra read throughput
- Mapping- defines each field's type and how it is indexed
- Analyzer- tokenizes and normalizes text so it can be searched
- Inverted index- the core structure mapping terms to the documents containing them
Aggregations
Computing metrics and buckets over search results.
bash
GET /products/_search{ "size": 0, "aggs": { "avg_price": { "avg": { "field": "price" } }, "by_category": { "terms": { "field": "category.keyword" } } }}
Pro Tip
Use the .keyword sub-field (e.g. category.keyword) for exact-match filtering, sorting, and aggregations — plain "text" fields are analyzed/tokenized and won't behave as you expect for those operations.
Was this cheat sheet helpful?
Explore Topics
#Elasticsearch#ElasticsearchCheatSheet#Database#Intermediate#RESTAPIBasics#SearchQueries#CoreConcepts#Aggregations#Algorithms#Databases#APIs#CheatSheet#SkillVeris
Advertisement
Sri Hayavadhana Info-Tech
Professional Web Designing Services
- Responsive Websites
- E-commerce Solutions
- SEO Friendly Design
- Fast & Secure
- Support & Maintenance