Elasticsearch Tutorial 120 lessons · 1:53:19+ of video
Elasticsearch Home What Is Elasticsearch
What Is Elasticsearch Why Not SQL LIKE The Inverted Index Documents, Clusters and Setup
Documents and Indexes Nodes, Shards and Clusters Running Elasticsearch Kibana and Your First Requests
Kibana Dev Tools Your First Request Cluster Health and _cat Indexes and Documents
Creating an Index Indexing a Document Getting a Document Create, Update, Delete
Auto IDs with POST Updating Documents Deleting Documents Versions, Bulk and Refresh
Versions and Conflicts The Bulk API Counting and Refresh Multi Get and By Query
Multi Get Update and Delete by Query Practice: Load the Catalog Your First Searches
Your First Search Reading the Response The match Query Phrases and Many Fields
AND or OR match_phrase multi_match Exact Values and Ranges
term on Keywords terms and ids range More Queries, Sorting and Paging
exists, prefix and wildcard Sorting Paging and _source The bool Query
The bool Query filter: No Scores should and Boosting Excluding and Context
must_not Query vs Filter Context Practice: A Real Shop Query Mappings
Dynamic Mapping Explicit Mappings text vs keyword Field Types in Depth
Multi-fields Numbers, Dates, Booleans Objects and Arrays Nested, Reindex and Aliases
The nested Type Changing a Mapping: Reindex Aliases Templates and Strict Mappings
Index Templates Strict Mappings Practice: Design the Catalog Mapping Text Analysis
How Analysis Works The _analyze API Built-in Analyzers Stemming, Synonyms and Custom Analyzers
Stop Words and Stemming Synonyms Custom Analyzers Normalizers and Autocomplete
Normalizers Autocomplete with Edge N-grams search_as_you_type Relevance and Scoring
How Scoring Works The explain API Field Boosting Custom Scoring and Typos
function_score Decay Functions Fuzzy Matching Better Ranking and Aggregations
Practice: Better Ranking Aggregations terms Aggregation Metrics and Statistics
Metric Aggregations stats and Percentiles Aggregating a Search Ranges and Histograms
range Aggregation histogram date_histogram Sub-aggregations, Cardinality, top_hits
Sub-aggregations cardinality top_hits Facets and Dashboards
Facets with post_filter Pipeline Aggregations Practice: A Sales Dashboard Highlighting and Suggestions
Highlighting Completion Suggester Did You Mean Deep Paging, collapse and Geo
Deep Paging with search_after collapse Geo Search Elasticsearch from Python
The Python Client Indexing from Python Bulk Helpers Searching and Errors in Python
Searching from Python Aggregations in Python Errors and Retries Scan, FastAPI and a Search Service
Scanning Every Document A Search API with FastAPI Practice: Python Search Service Semantic Search and Vectors
Keyword vs Semantic Search Embeddings dense_vector kNN, Filters and Hybrid Search
kNN Search Filtered kNN Hybrid Search RAG, Ingest Pipelines and Runtime Fields
RAG with Elasticsearch Ingest Pipelines Runtime Fields Shards, Health and Performance
Shards and Replicas Health Colors Refresh and Performance Data Streams, Snapshots and Security
Data Streams and ILM Snapshots Security Basics Monitoring, Mistakes and OpenSearch
Monitoring Common Mistakes Elasticsearch vs OpenSearch Project: Trailhead Search
Project: Trailhead Search Project: Search and Facets Project: Autocomplete and Ranking Cheat Sheet, Interview and Roadmap
Cheat Sheet Interview Questions Wrap-up and Roadmap Elasticsearch · Lesson 16 of 120
Versions and Conflicts Two writers at once.
⏱ 2 min read ▶ Video at 14:19 🎓 Free
▶ starts at 14:19 Two staff members open the same product at once. Both change the stock, and both save. Without care, one change silently overwrites the other. This is called a lost update.
Two people edit Both save One change is lost Each change gets a sequence number, and a primary term. We read them with the document. Run it. Sequence number zero, primary term one. Together, they say exactly which version we read.
Dev Tools Console text Copy
GET products/_doc/1?filter_path=_seq_no,_primary_term,_source Output
{
"_seq_no": 0,
"_primary_term": 1,
"_source": {
"name": "Basecamp 2-Person Tent",
"price": 237.99,
"stock": 5
}
} Also uses _setup.http PUT products
{ "settings" : { "number_of_replicas" : 0 } }
PUT products / _doc / 1 ? refresh = true
{ "name" : "Basecamp 2-Person Tent" , "price" : 237.99 , "stock" : 5 } The first update says, only save if the document is still at sequence number zero. It works, and the number moves on to one. The second writer still thinks it's zero. Run it. The second write fails with a conflict, so nothing is lost.
Dev Tools Console text Copy
PUT products/_doc/1?if_seq_no=0&if_primary_term=1&filter_path=result,_seq_no
{ "name": "Basecamp 2-Person Tent", "price": 237.99, "stock": 4 }
PUT products/_doc/1?if_seq_no=0&if_primary_term=1&filter_path=result
{ "name": "Basecamp 2-Person Tent", "price": 237.99, "stock": 3 } Output
# PUT products/_doc/1 200 OK
{"result": "updated", "_seq_no": 1}
# PUT products/_doc/1 409 Conflict
{
"error": {
"type": "version_conflict_engine_exception",
"reason": "[1]: version conflict, required seqNo [0], primary term [1]. current
document has seqNo [1] and primary term [1]"
},
"status": 409
} Also uses _setup.http PUT products
{ "settings" : { "number_of_replicas" : 0 } }
PUT products / _doc / 1 ? refresh = true
{ "name" : "Basecamp 2-Person Tent" , "price" : 237.99 , "stock" : 5 } Prefer to watch? The full Elasticsearch course is free All lessons in one video with animations, real code and chapters.
Watch free Use if seq no and if primary term to save only if nobody else changed the document. A conflict tells you to read it again and retry. Next, writing many documents at once.
Key takeaways _seq_no if_seq_no 409 conflict