JBStrap Elasticsearch DataDescriptor

ElasticSearch DataDescriptors are used to describe the structure of the data stored in the ElasticSearch index. ElasticSearch DataDescriptors access data through the ElasticSearch DAO layer. DataDescriptors require the use of entity classes. ElasticSearch DataDescriptors allow you to read and write the data stored in the ElasticSearch index.

Creating a simple ElasticSearch DataDescriptor with an XML structure:

Programmatically creating an ElasticSearch DataDescriptor that corresponds to the above XML:

ElasticSearch DataDescriptors can perform any type of data handling operation, you can read data from the ElasticSearch index and you can update or remove existing data.

Fetching all documents from the ElasticSearch index using the data descriptor:

Fetching all documents corresponding to the given criteria from the ElasticSearch index using the data descriptor:

Fetching a document using its ID:

Saving a document to the ElasticSearch index using a data descriptor:

Removing a record using a data descriptor:

Data descriptors also support transaction handling. To handle a transaction, you need to specify an ESTransaction for the DataDescriptor.

Fetching a document, upadting and saving it within a single transaction: