Indexing a document
In ElasticSearch, there are two vital operations namely, Indexing and Searching.
Indexing means inserting one or more document in an index; this is similar to the insert
command of a relational database.
In Lucene, the core engine of ElasticSearch, inserting or updating a document has the same cost. In Lucene and ElasticSearch, update means replace.
Getting ready
You will need a working ElasticSearch cluster and the mapping that was created in the Putting a mapping in an index recipe in this chapter.
How to do it...
To index a document, several REST entry points can be used:
Method |
URL |
---|---|
POST |
http://<server>/<index_name>/<type> |
PUT/POST |
http://<server>/<index_name>/<type> /<id> |
PUT/POST |
http://<server>/<index_name>/<type> /<id>/_create ... |
Get ElasticSearch Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.