Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Learning Elasticsearch

You're reading from   Learning Elasticsearch Structured and unstructured data using distributed real-time search and analytics

Arrow left icon
Product type Paperback
Published in Jun 2017
Publisher Packt
ISBN-13 9781787128453
Length 404 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
 Andhavarapu Andhavarapu
Author Profile Icon Andhavarapu
Andhavarapu
Arrow right icon
View More author details
Toc

Table of Contents (17) Chapters Close

Title Page
Credits
About the Author
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface
1. Introduction to Elasticsearch 2. Setting Up Elasticsearch and Kibana FREE CHAPTER 3. Modeling Your Data and Document Relations 4. Indexing and Updating Your Data 5. Organizing Your Data and Bulk Data Ingestion 6. All About Search 7. More Than a Search Engine (Geofilters, Autocomplete, and More) 8. How to Slice and Dice Your Data Using Aggregations 9. Production and Beyond 10. Exploring Elastic Stack (Elastic Cloud, Security, Graph, and Alerting)

Updating your data


In this section, we will discuss different ways of updating existing documents. Internally, an update is always a delete and re-index. You can update using the entire document (replacing the original document), or update a single field or add a new field, or update a field using scripts, such as incrementing a counter.

Update using an entire document

When you index a document with the existing document ID, it will replace the current document with the new document. As shown next, we can update the document ID 1 using the entire document:

 PUT chapter4/person/1
 {
   "id": 1,
"name": "name update 1",
   "age": 55,
   "gender": "M",
   "email": "[email protected]",
   "last_modified_date": "2017-02-15"
 }

The response is as follows:

{
   "_index": "chapter4",
   "_type": "person",
   "_id": "1",
"_version": 2,
 "result": "updated",
   "_shards": {
     "total": 2,
     "successful": 1,
     "failed": 0
   },
"created": false
 }

You can see from the response that the result of the...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images