Search in sources :

Example 1 with ByQueryResponse

use of org.springframework.data.elasticsearch.core.query.ByQueryResponse in project spring-data-elasticsearch by spring-projects.

the class ReactiveElasticsearchTemplate method updateByQuery.

@Override
public Mono<ByQueryResponse> updateByQuery(UpdateQuery updateQuery, IndexCoordinates index) {
    Assert.notNull(updateQuery, "updateQuery must not be null");
    Assert.notNull(index, "Index must not be null");
    return Mono.defer(() -> {
        final UpdateByQueryRequest request = requestFactory.updateByQueryRequest(updateQuery, index);
        if (updateQuery.getRefreshPolicy() == null && refreshPolicy != null) {
            request.setRefresh(refreshPolicy == RefreshPolicy.IMMEDIATE);
        }
        if (updateQuery.getRouting() == null && routingResolver.getRouting() != null) {
            request.setRouting(routingResolver.getRouting());
        }
        return Mono.from(execute(client -> client.updateBy(request)));
    });
}
Also used : DefaultReactiveClusterOperations(org.springframework.data.elasticsearch.core.cluster.DefaultReactiveClusterOperations) QueryBuilders(org.elasticsearch.index.query.QueryBuilders) ElasticsearchPersistentEntity(org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentEntity) PersistentPropertyAccessor(org.springframework.data.mapping.PersistentPropertyAccessor) BulkFailureException(org.springframework.data.elasticsearch.BulkFailureException) DeleteRequest(org.elasticsearch.action.delete.DeleteRequest) IndexRequest(org.elasticsearch.action.index.IndexRequest) ReindexRequest(org.springframework.data.elasticsearch.core.reindex.ReindexRequest) VersionInfo(org.springframework.data.elasticsearch.support.VersionInfo) MappingElasticsearchConverter(org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter) Map(java.util.Map) RoutingResolver(org.springframework.data.elasticsearch.core.routing.RoutingResolver) IndicesOptions(org.elasticsearch.action.support.IndicesOptions) DeleteByQueryRequest(org.elasticsearch.index.reindex.DeleteByQueryRequest) ElasticsearchPersistentProperty(org.springframework.data.elasticsearch.core.mapping.ElasticsearchPersistentProperty) GetRequest(org.elasticsearch.action.get.GetRequest) ReactiveEntityCallbacks(org.springframework.data.mapping.callback.ReactiveEntityCallbacks) IndexCoordinates(org.springframework.data.elasticsearch.core.mapping.IndexCoordinates) UpdateQuery(org.springframework.data.elasticsearch.core.query.UpdateQuery) BulkItemResponse(org.elasticsearch.action.bulk.BulkItemResponse) ReactiveClusterOperations(org.springframework.data.elasticsearch.core.cluster.ReactiveClusterOperations) Collection(java.util.Collection) BulkResponse(org.elasticsearch.action.bulk.BulkResponse) IndexQuery(org.springframework.data.elasticsearch.core.query.IndexQuery) Collectors(java.util.stream.Collectors) List(java.util.List) Version(org.elasticsearch.Version) NonNull(org.springframework.lang.NonNull) LogFactory(org.apache.commons.logging.LogFactory) SearchDocument(org.springframework.data.elasticsearch.core.document.SearchDocument) ApplicationContextAware(org.springframework.context.ApplicationContextAware) Document(org.springframework.data.elasticsearch.core.document.Document) ReactiveBeforeConvertCallback(org.springframework.data.elasticsearch.core.event.ReactiveBeforeConvertCallback) ReactiveAfterSaveCallback(org.springframework.data.elasticsearch.core.event.ReactiveAfterSaveCallback) SeqNoPrimaryTerm(org.springframework.data.elasticsearch.core.query.SeqNoPrimaryTerm) Suggest(org.springframework.data.elasticsearch.core.suggest.response.Suggest) GetResult(org.elasticsearch.index.get.GetResult) Tuple2(reactor.util.function.Tuple2) MultiGetRequest(org.elasticsearch.action.get.MultiGetRequest) HashMap(java.util.HashMap) Query(org.springframework.data.elasticsearch.core.query.Query) SearchRequest(org.elasticsearch.action.search.SearchRequest) BulkOptions(org.springframework.data.elasticsearch.core.query.BulkOptions) EntityReader(org.springframework.data.convert.EntityReader) SearchDocumentResponse(org.springframework.data.elasticsearch.core.document.SearchDocumentResponse) WriteRequest(org.elasticsearch.action.support.WriteRequest) DocumentAdapters(org.springframework.data.elasticsearch.core.document.DocumentAdapters) ByQueryResponse(org.springframework.data.elasticsearch.core.query.ByQueryResponse) ElasticsearchConverter(org.springframework.data.elasticsearch.core.convert.ElasticsearchConverter) ReactiveAfterLoadCallback(org.springframework.data.elasticsearch.core.event.ReactiveAfterLoadCallback) IndexResponse(org.elasticsearch.action.index.IndexResponse) Nullable(org.springframework.lang.Nullable) UpdateResponse(org.springframework.data.elasticsearch.core.query.UpdateResponse) UpdateByQueryRequest(org.elasticsearch.index.reindex.UpdateByQueryRequest) BulkByScrollResponse(org.elasticsearch.index.reindex.BulkByScrollResponse) Publisher(org.reactivestreams.Publisher) Mono(reactor.core.publisher.Mono) UpdateRequest(org.elasticsearch.action.update.UpdateRequest) BeansException(org.springframework.beans.BeansException) SimpleElasticsearchMappingContext(org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext) ReactiveElasticsearchClient(org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient) DocWriteResponse(org.elasticsearch.action.DocWriteResponse) ApplicationContext(org.springframework.context.ApplicationContext) SuggestBuilder(org.elasticsearch.search.suggest.SuggestBuilder) Flux(reactor.core.publisher.Flux) HttpStatus(org.springframework.http.HttpStatus) AdaptibleEntity(org.springframework.data.elasticsearch.core.EntityOperations.AdaptibleEntity) ReactiveAfterConvertCallback(org.springframework.data.elasticsearch.core.event.ReactiveAfterConvertCallback) NoSuchIndexException(org.springframework.data.elasticsearch.NoSuchIndexException) DefaultRoutingResolver(org.springframework.data.elasticsearch.core.routing.DefaultRoutingResolver) Log(org.apache.commons.logging.Log) NativeSearchQueryBuilder(org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder) BulkRequest(org.elasticsearch.action.bulk.BulkRequest) ReindexResponse(org.springframework.data.elasticsearch.core.reindex.ReindexResponse) UncategorizedElasticsearchException(org.springframework.data.elasticsearch.UncategorizedElasticsearchException) Assert(org.springframework.util.Assert) UpdateByQueryRequest(org.elasticsearch.index.reindex.UpdateByQueryRequest)

Aggregations

Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Log (org.apache.commons.logging.Log)1 LogFactory (org.apache.commons.logging.LogFactory)1 Version (org.elasticsearch.Version)1 DocWriteResponse (org.elasticsearch.action.DocWriteResponse)1 BulkItemResponse (org.elasticsearch.action.bulk.BulkItemResponse)1 BulkRequest (org.elasticsearch.action.bulk.BulkRequest)1 BulkResponse (org.elasticsearch.action.bulk.BulkResponse)1 DeleteRequest (org.elasticsearch.action.delete.DeleteRequest)1 GetRequest (org.elasticsearch.action.get.GetRequest)1 MultiGetRequest (org.elasticsearch.action.get.MultiGetRequest)1 IndexRequest (org.elasticsearch.action.index.IndexRequest)1 IndexResponse (org.elasticsearch.action.index.IndexResponse)1 SearchRequest (org.elasticsearch.action.search.SearchRequest)1 IndicesOptions (org.elasticsearch.action.support.IndicesOptions)1 WriteRequest (org.elasticsearch.action.support.WriteRequest)1