public class ElasticsearchRestTemplate extends AbstractElasticsearchTemplate
Modifier and Type | Class and Description |
---|---|
static interface |
ElasticsearchRestTemplate.ClientCallback<T>
Callback interface to be used with
execute(ClientCallback) for operating directly on
RestHighLevelClient . |
AbstractElasticsearchTemplate.DocumentCallback<T>, AbstractElasticsearchTemplate.ReadDocumentCallback<T>, AbstractElasticsearchTemplate.ReadSearchDocumentResponseCallback<T>, AbstractElasticsearchTemplate.ReadSearchScrollDocumentResponseCallback<T>, AbstractElasticsearchTemplate.SearchDocumentResponseCallback<T>
elasticsearchConverter, requestFactory
Constructor and Description |
---|
ElasticsearchRestTemplate(org.elasticsearch.client.RestHighLevelClient client) |
ElasticsearchRestTemplate(org.elasticsearch.client.RestHighLevelClient client,
ElasticsearchConverter elasticsearchConverter) |
Modifier and Type | Method and Description |
---|---|
List<String> |
bulkIndex(List<IndexQuery> queries,
BulkOptions bulkOptions,
IndexCoordinates index)
Bulk index all objects.
|
void |
bulkUpdate(List<UpdateQuery> queries,
BulkOptions bulkOptions,
IndexCoordinates index)
Bulk update all objects.
|
long |
count(Query query,
Class<?> clazz,
IndexCoordinates index)
return number of elements found by given query
|
void |
delete(DeleteQuery deleteQuery,
IndexCoordinates index)
Deprecated.
|
void |
delete(Query query,
Class<?> clazz,
IndexCoordinates index)
Delete all records matching the query.
|
String |
delete(String id,
IndexCoordinates index)
Delete the one object with provided id.
|
protected boolean |
doExists(String id,
IndexCoordinates index) |
<T> T |
execute(ElasticsearchRestTemplate.ClientCallback<T> callback)
Execute a callback with the
RestHighLevelClient |
<T> T |
get(String id,
Class<T> clazz,
IndexCoordinates index)
Retrieves an object from the index specified in the entity's Document annotation.
|
protected String |
getClusterVersion()
tries to extract the version of the Elasticsearch cluster
|
protected org.elasticsearch.action.search.MultiSearchResponse.Item[] |
getMultiSearchResult(org.elasticsearch.action.search.MultiSearchRequest request) |
String |
index(IndexQuery query,
IndexCoordinates index)
Index an object.
|
IndexOperations |
indexOps(Class<?> clazz)
get an
IndexOperations that is bound to the given class |
IndexOperations |
indexOps(IndexCoordinates index)
get an
IndexOperations that is bound to the given class |
<T> List<T> |
multiGet(Query query,
Class<T> clazz,
IndexCoordinates index)
Execute a multiGet against elasticsearch for the given ids.
|
<T> SearchHits<T> |
search(Query query,
Class<T> clazz,
IndexCoordinates index)
Execute the criteria query against elasticsearch and return result as
SearchHits |
void |
searchScrollClear(List<String> scrollIds) |
<T> SearchScrollHits<T> |
searchScrollContinue(String scrollId,
long scrollTimeInMillis,
Class<T> clazz,
IndexCoordinates index) |
<T> SearchScrollHits<T> |
searchScrollStart(long scrollTimeInMillis,
Query query,
Class<T> clazz,
IndexCoordinates index) |
org.elasticsearch.action.search.SearchResponse |
suggest(org.elasticsearch.search.suggest.SuggestBuilder suggestion,
IndexCoordinates index)
Does a suggest query
|
UpdateResponse |
update(UpdateQuery query,
IndexCoordinates index)
Partial update of the document.
|
checkForBulkOperationFailure, count, createElasticsearchConverter, delete, delete, delete, exists, exists, get, get, getElasticsearchConverter, getIndexCoordinatesFor, getRequestFactory, initialize, maybeCallbackAfterConvert, maybeCallbackAfterSave, maybeCallbackAfterSaveWithQueries, maybeCallbackAfterSaveWithQuery, maybeCallbackBeforeConvert, maybeCallbackBeforeConvertWithQueries, maybeCallbackBeforeConvertWithQuery, multiSearch, multiSearch, queryForObject, save, save, save, save, save, search, search, search, searchForStream, searchForStream, searchScrollClear, setApplicationContext, setEntityCallbacks, setPersistentEntityId, stream, toArray
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addAlias, createIndex, createIndex, createIndex, createIndex, deleteIndex, deleteIndex, deleteIndex, getDocument, getMapping, getMapping, getSetting, getSetting, getSettings, getSettings, indexExists, indexExists, putMapping, putMapping, putMapping, putMapping, queryForAlias, refresh, refresh, removeAlias, stringIdRepresentation
bulkIndex, bulkUpdate
count, moreLikeThis, queryForIds, queryForList, queryForList, queryForList, queryForObject, queryForPage, queryForPage, queryForPage, searchOne, searchOne
public ElasticsearchRestTemplate(org.elasticsearch.client.RestHighLevelClient client)
public ElasticsearchRestTemplate(org.elasticsearch.client.RestHighLevelClient client, ElasticsearchConverter elasticsearchConverter)
public IndexOperations indexOps(Class<?> clazz)
ElasticsearchOperations
IndexOperations
that is bound to the given classpublic IndexOperations indexOps(IndexCoordinates index)
ElasticsearchOperations
IndexOperations
that is bound to the given classpublic String index(IndexQuery query, IndexCoordinates index)
DocumentOperations
query
- the query defining the objectindex
- the index where the object is stored.@Nullable public <T> T get(String id, Class<T> clazz, IndexCoordinates index)
DocumentOperations
id
- the id of the objectclazz
- the entity class,index
- the index from which the object is read.public <T> List<T> multiGet(Query query, Class<T> clazz, IndexCoordinates index)
DocumentOperations
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.protected boolean doExists(String id, IndexCoordinates index)
doExists
in class AbstractElasticsearchTemplate
public List<String> bulkIndex(List<IndexQuery> queries, BulkOptions bulkOptions, IndexCoordinates index)
DocumentOperations
queries
- the queries to execute in bulkbulkOptions
- options to be added to the bulk requestpublic void bulkUpdate(List<UpdateQuery> queries, BulkOptions bulkOptions, IndexCoordinates index)
DocumentOperations
queries
- the queries to execute in bulkbulkOptions
- options to be added to the bulk requestpublic String delete(String id, IndexCoordinates index)
DocumentOperations
id
- the document ot deleteindex
- the index from which to deletepublic void delete(Query query, Class<?> clazz, IndexCoordinates index)
DocumentOperations
query
- query defining the objectsclazz
- The entity class, must be annotated with
Document
index
- the index from which to delete@Deprecated public void delete(DeleteQuery deleteQuery, IndexCoordinates index)
DocumentOperations
deleteQuery
- query defining the objectsindex
- the index where to delete the recordspublic UpdateResponse update(UpdateQuery query, IndexCoordinates index)
DocumentOperations
query
- query defining the updateindex
- the index where to update the recordspublic long count(Query query, @Nullable Class<?> clazz, IndexCoordinates index)
SearchOperations
query
- the query to executeclazz
- the entity clazz used for property mappingindex
- the index to run the query againstpublic <T> SearchHits<T> search(Query query, Class<T> clazz, IndexCoordinates index)
SearchOperations
SearchHits
T
- element return typequery
- the query to executeclazz
- the entity clazz used for property mappingindex
- the index to run the query againstpublic <T> SearchScrollHits<T> searchScrollStart(long scrollTimeInMillis, Query query, Class<T> clazz, IndexCoordinates index)
searchScrollStart
in class AbstractElasticsearchTemplate
public <T> SearchScrollHits<T> searchScrollContinue(@Nullable String scrollId, long scrollTimeInMillis, Class<T> clazz, IndexCoordinates index)
searchScrollContinue
in class AbstractElasticsearchTemplate
public void searchScrollClear(List<String> scrollIds)
searchScrollClear
in class AbstractElasticsearchTemplate
public org.elasticsearch.action.search.SearchResponse suggest(org.elasticsearch.search.suggest.SuggestBuilder suggestion, IndexCoordinates index)
SearchOperations
suggestion
- the queryindex
- the index to run the query againstprotected org.elasticsearch.action.search.MultiSearchResponse.Item[] getMultiSearchResult(org.elasticsearch.action.search.MultiSearchRequest request)
getMultiSearchResult
in class AbstractElasticsearchTemplate
public <T> T execute(ElasticsearchRestTemplate.ClientCallback<T> callback)
RestHighLevelClient
T
- the type returned from the callbackcallback
- the callback to execute, must not be nullprotected String getClusterVersion()
AbstractElasticsearchTemplate
getClusterVersion
in class AbstractElasticsearchTemplate
Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.