Indexing a document
In ElasticSearch there are two vital operations: index and search.
Index consists of putting one or more documents in an index: it is similar to the concept of inserting records in a relational database.
In Lucene, the core engine of ElasticSearch, inserting or updating a document has the same cost: in Lucene update means replace.
Getting ready
You need a working ElasticSearch cluster and the mapping created in the Putting a mapping in an index recipe.
How to do it...
For indexing a document, several REST entry points that can be used are as follows:
Method |
URL |
---|---|
POST |
|
PUT/POST |
|
PUT/POST |
|
For indexing a document, we need to perform the following steps:
If we consider the type
order
of the previous chapter, the call to index a document will be as follows:curl -XPOST 'http://localhost...