Elasticsearch and NoSql database [duplicate] Elasticsearch and NoSql database [duplicate] elasticsearch elasticsearch

Elasticsearch and NoSql database [duplicate]


Yes, you can use ElasticSearch as a data source as well as an index.

By default each document you send to the ElasticSearch system is index, and, the original document is stored as well. This means whenever you query ElasticSearch you can also retrieve the original JSON document that you indexed.

If you have large documents and you want to be able to retrieve a smaller amount of data then when you can use the mapping API to set "store" to "yes" for specific fields, and then use the "fields" key to pull out specific fields you might want.

In my system I have address autocompletion and I only fetch the address field of a property. Here is an example from my system:

_search?q=FullAddress:main&fields:FullAddress

Then when a user selects the address I pull up the entire JSON document (along with others).

Note:

  1. You cannot do updates like you can in SQL (update all items matching a query to increase an attribute, let's say)
  2. You can, however, add a new document and replace the existing one at the ID you want to update. Elastic search increments a _version property on each document which can be used by the developer to enforce optimistic concurrency, but it does not maintain a separate version history of each document. You can only retrieve the latest version of a document.