Interface DocumentOperations
- All Known Subinterfaces:
ElasticsearchOperations
- All Known Implementing Classes:
AbstractElasticsearchTemplate
,ElasticsearchTemplate
public interface DocumentOperations
The operations for the
Elasticsearch Document APIs.
- Since:
- 4.0
- Author:
- Peter-Josef Meisch, Farid Faoudi, Sijia Liu, Haibo Liu
-
Method Summary
Modifier and TypeMethodDescriptiondefault List<IndexedObjectInformation>
bulkIndex
(List<IndexQuery> queries, Class<?> clazz) Bulk index all objects.default List<IndexedObjectInformation>
bulkIndex
(List<IndexQuery> queries, IndexCoordinates index) Bulk index all objects.bulkIndex
(List<IndexQuery> queries, BulkOptions bulkOptions, Class<?> clazz) Bulk index all objects.bulkIndex
(List<IndexQuery> queries, BulkOptions bulkOptions, IndexCoordinates index) Bulk index all objects.void
bulkUpdate
(List<UpdateQuery> queries, Class<?> clazz) Bulk update all objects.default void
bulkUpdate
(List<UpdateQuery> queries, IndexCoordinates index) Bulk update all objects.void
bulkUpdate
(List<UpdateQuery> queries, BulkOptions bulkOptions, IndexCoordinates index) Bulk update all objects.Deletes the given entitydelete
(Object entity, IndexCoordinates index) Deletes the given entityDelete the one object with provided id.delete
(String id, IndexCoordinates index) Delete the one object with provided id.delete
(DeleteQuery query, Class<?> clazz) Delete all records matching the query.delete
(DeleteQuery query, Class<?> clazz, IndexCoordinates index) Delete all records matching the query.boolean
Check if an entity with given id exists.boolean
exists
(String id, IndexCoordinates index) Check if an entity with given id exists.<T> T
Retrieves an object from the index specified in the entity's Document annotation.<T> T
get
(String id, Class<T> clazz, IndexCoordinates index) Retrieves an object from the index specified in the entity's Document annotation.index
(IndexQuery query, IndexCoordinates index) Index an object.<T> List<MultiGetItem<T>>
Execute a multiGet against elasticsearch for the given ids.<T> List<MultiGetItem<T>>
multiGet
(Query query, Class<T> clazz, IndexCoordinates index) Execute a multiGet against elasticsearch for the given ids.reindex
(ReindexRequest reindexRequest) Copies documents from a source to a destination.<T> Iterable<T>
saves the given entities to the index retrieved from the entities' Document annotation<T> Iterable<T>
save
(Iterable<T> entities, IndexCoordinates index) saves the given entities to the given index<T> T
save
(T entity) Saves an entity to the index specified in the entity's Document annotation<T> Iterable<T>
save
(T... entities) saves the given entities to the index retrieved from the entities' Document annotation<T> T
save
(T entity, IndexCoordinates index) Saves an entity to the index specified in the entity's Document annotationsubmitReindex
(ReindexRequest reindexRequest) Submits a reindex task.update
(UpdateQuery updateQuery, IndexCoordinates index) Partial update of the document.<T> UpdateResponse
update
(T entity) Partially update a document by the given entity.<T> UpdateResponse
update
(T entity, IndexCoordinates index) Partially update a document by the given entity.updateByQuery
(UpdateQuery updateQuery, IndexCoordinates index) Update document(s) by query
-
Method Details
-
save
<T> T save(T entity) Saves an entity to the index specified in the entity's Document annotation- Type Parameters:
T
- the entity type- Parameters:
entity
- the entity to save, must not be null- Returns:
- the saved entity
-
save
Saves an entity to the index specified in the entity's Document annotation- Type Parameters:
T
- the entity type- Parameters:
entity
- the entity to save, must not be nullindex
- the index to save the entity in, must not be null- Returns:
- the saved entity
-
save
saves the given entities to the index retrieved from the entities' Document annotation- Type Parameters:
T
- the entity type- Parameters:
entities
- must not be null- Returns:
- the saved entites
-
save
saves the given entities to the given index- Type Parameters:
T
- the entity type- Parameters:
entities
- must not be nullindex
- the index to save the entities in, must not be null- Returns:
- the saved entities
-
save
saves the given entities to the index retrieved from the entities' Document annotation- Type Parameters:
T
- the entity type- Parameters:
entities
- must not be null- Returns:
- the saved entities as Iterable
-
index
Index an object. Will do save or update.- Parameters:
query
- the query defining the objectindex
- the index where the object is stored.- Returns:
- returns the document id
-
get
Retrieves an object from the index specified in the entity's Document annotation.- Type Parameters:
T
- the entity type- Parameters:
id
- the id of the objectclazz
- the entity class,- Returns:
- the entity
-
get
Retrieves an object from the index specified in the entity's Document annotation.- Parameters:
id
- the id of the objectclazz
- the entity class,index
- the index from which the object is read.- Returns:
- the entity
-
multiGet
Execute a multiGet against elasticsearch for the given ids.- Parameters:
query
- the query defining the ids of the objects to getclazz
- the type of the object to be returned- Returns:
- list of
MultiGetItem
s - Since:
- 4.1
- See Also:
-
multiGet
Execute a multiGet against elasticsearch for the given ids.- Parameters:
query
- the query defining the ids of the objects to getclazz
- the type of the object to be returnedindex
- the index(es) from which the objects are read.- Returns:
- list of
MultiGetItem
s - See Also:
-
exists
Check if an entity with given id exists.- Parameters:
id
- the _id of the document to look for.clazz
- the domain type used.- Returns:
- true if a matching document exists, false otherwise.
-
exists
Check if an entity with given id exists.- Parameters:
id
- the _id of the document to look for.index
- the target index, must not be null- Returns:
- true if a matching document exists, false otherwise.
-
bulkIndex
Bulk index all objects. Will do save or update.- Parameters:
queries
- the queries to execute in bulkclazz
- the entity class- Returns:
- the information about the indexed objects
- Throws:
BulkFailureException
- with information about the failed operation- Since:
- 4.1
-
bulkIndex
Bulk index all objects. Will do save or update.- Parameters:
queries
- the queries to execute in bulk- Returns:
- the information about of the indexed objects
- Throws:
BulkFailureException
- with information about the failed operation
-
bulkIndex
List<IndexedObjectInformation> bulkIndex(List<IndexQuery> queries, BulkOptions bulkOptions, Class<?> clazz) Bulk index all objects. Will do save or update.- Parameters:
queries
- the queries to execute in bulkbulkOptions
- options to be added to the bulk requestclazz
- the entity class- Returns:
- the information about of the indexed objects
- Throws:
BulkFailureException
- with information about the failed operation- Since:
- 4.1
-
bulkIndex
List<IndexedObjectInformation> bulkIndex(List<IndexQuery> queries, BulkOptions bulkOptions, IndexCoordinates index) Bulk index all objects. Will do save or update.- Parameters:
queries
- the queries to execute in bulkbulkOptions
- options to be added to the bulk request- Returns:
- the information about of the indexed objects
- Throws:
BulkFailureException
- with information about the failed operation
-
bulkUpdate
Bulk update all objects. Will do update.- Parameters:
queries
- the queries to execute in bulk- Throws:
BulkFailureException
- with information about the failed operation
-
bulkUpdate
Bulk update all objects. Will do update.- Parameters:
clazz
- the entity classqueries
- the queries to execute in bulk- Throws:
BulkFailureException
- with information about the failed operation- Since:
- 4.1
-
bulkUpdate
Bulk update all objects. Will do update.- Parameters:
queries
- the queries to execute in bulkbulkOptions
- options to be added to the bulk request- Throws:
BulkFailureException
- with information about the failed operation
-
delete
Delete the one object with provided id.- Parameters:
id
- the document to deleteindex
- the index from which to delete- Returns:
- documentId of the document deleted
-
delete
Delete the one object with provided id.- Parameters:
id
- the document ot deleteentityType
- must not be null.- Returns:
- documentId of the document deleted
-
delete
Deletes the given entity- Parameters:
entity
- the entity to delete- Returns:
- documentId of the document deleted
-
delete
Deletes the given entity- Parameters:
entity
- the entity to deleteindex
- the index from which to delete- Returns:
- documentId of the document deleted
-
delete
Delete all records matching the query.- Parameters:
query
- query defining the objectsclazz
- The entity class must be annotated withDocument
- Returns:
- response with detailed information
- Since:
- 5.3
-
delete
Delete all records matching the query.- Parameters:
query
- query defining the objectsclazz
- The entity class must be annotated withDocument
index
- the index from which to delete- Returns:
- response with detailed information
- Since:
- 5.3
-
update
Partially update a document by the given entity.- Type Parameters:
T
- the entity type- Parameters:
entity
- the entity to update partially, must not be null.- Returns:
- the update response
- Since:
- 5.0
-
update
Partially update a document by the given entity.- Type Parameters:
T
- the entity type- Parameters:
entity
- the entity to update partially, must not be null.index
- the index to use for the update instead of the one defined by the entity, must not be null- Returns:
- the update response
- Since:
- 5.1
-
update
Partial update of the document.- Parameters:
updateQuery
- query defining the updateindex
- the index where to update the records- Returns:
- the update response
-
updateByQuery
Update document(s) by query- Parameters:
updateQuery
- query defining the update, must not be nullindex
- the index where to update the records , must not be null- Returns:
- the update response
- Since:
- 4.2
-
reindex
Copies documents from a source to a destination. The source can be any existing index, alias, or data stream. The destination must differ from the source. For example, you cannot reindex a data stream into itself. (@see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html)- Parameters:
reindexRequest
- reindex request parameters- Returns:
- the reindex response
- Since:
- 4.4
-
submitReindex
Submits a reindex task. (@see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html)- Parameters:
reindexRequest
- reindex request parameters- Returns:
- the task id
- Since:
- 4.4
-