Elasticsearch Transaction Handling

Using ElasticSearch transactions is different from conventional database transactions. ElasticSearch does not support transaction handling, but uses a batch implementation. Transaction handling in the JBStrap framework is also executed on the server in batches. Consequently, statements in a transaction are not executed immediately, only when the transaction is closed.

Always begin implementing a transaction by creating the transaction object. The transaction object identifies the transaction itself. You have two options to close a transaction. The first option is to commit the updates and the second one is to roll them back. Once you commit a transaction, the statements in the transaction are executed and the updates become available to all users.

If you roll back a transaction, statements in that transaction are not executed, and all further queries return the data in their original state (before the transaction).

You can use the transaction in JBStrap's ElasticSearch plugin with all components capable of data handling. Also, you can use ElasticSearch plugin transactions with the ElasticSearchDao API and ElasticSearchDataDescriptor, but you cannot use them with transactions of other databases. Within an open transaction, you can write and read the data.

How to use ElasticSearch transactions with the ElasticSearchDao API

All functions of the ElasticSearchDao support transaction handling. If you make updates within a single transaction, you can approve them or roll them back at the same time.

An example of performing a database transaction. In the example, the balance of bank account A is reduced by $50 and increase bank balance B by $50:

How to use ElasticSearch transactions with the ElasticSearchDataDescriptor

If you use a DataDescriptor to implement transaction handling, all of the above is true for executing a transaction.

An example of performing a database transaction. In the example, the balance of bank account A is reduced by $50 and increase bank balance B by $50: