mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-20 11:02:10 +00:00
Remove deprecated suggest calls from operations.
Original Pull Request #2193 Closes #2192
This commit is contained in:
parent
96d0781f24
commit
bfc68699e0
@ -34,8 +34,6 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.elasticsearch.search.suggest.Suggest;
|
|
||||||
import org.elasticsearch.search.suggest.SuggestBuilder;
|
|
||||||
import org.reactivestreams.Publisher;
|
import org.reactivestreams.Publisher;
|
||||||
import org.springframework.data.elasticsearch.BulkFailureException;
|
import org.springframework.data.elasticsearch.BulkFailureException;
|
||||||
import org.springframework.data.elasticsearch.NoSuchIndexException;
|
import org.springframework.data.elasticsearch.NoSuchIndexException;
|
||||||
@ -177,8 +175,9 @@ public class ReactiveElasticsearchTemplate extends AbstractReactiveElasticsearch
|
|||||||
return Mono.from(execute( //
|
return Mono.from(execute( //
|
||||||
(ClientCallback<Publisher<co.elastic.clients.elasticsearch.core.ReindexResponse>>) client -> client
|
(ClientCallback<Publisher<co.elastic.clients.elasticsearch.core.ReindexResponse>>) client -> client
|
||||||
.reindex(reindexRequestES)))
|
.reindex(reindexRequestES)))
|
||||||
.flatMap(response -> (response.task() == null) ? Mono.error(
|
.flatMap(response -> (response.task() == null)
|
||||||
new UnsupportedBackendOperation("ElasticsearchClient did not return a task id on submit request"))
|
? Mono.error(
|
||||||
|
new UnsupportedBackendOperation("ElasticsearchClient did not return a task id on submit request"))
|
||||||
: Mono.just(response.task()));
|
: Mono.just(response.task()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,8 +345,7 @@ public class ReactiveElasticsearchTemplate extends AbstractReactiveElasticsearch
|
|||||||
return client1.scroll(scrollRequest, EntityAsMap.class);
|
return client1.scroll(scrollRequest, EntityAsMap.class);
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
},
|
}, this::cleanupScroll, (state, ex) -> cleanupScroll(state), this::cleanupScroll);
|
||||||
this::cleanupScroll, (state, ex) -> cleanupScroll(state), this::cleanupScroll);
|
|
||||||
|
|
||||||
return searchResponses.flatMapIterable(entityAsMapSearchResponse -> entityAsMapSearchResponse.hits().hits())
|
return searchResponses.flatMapIterable(entityAsMapSearchResponse -> entityAsMapSearchResponse.hits().hits())
|
||||||
.map(entityAsMapHit -> DocumentAdapters.from(entityAsMapHit, jsonpMapper));
|
.map(entityAsMapHit -> DocumentAdapters.from(entityAsMapHit, jsonpMapper));
|
||||||
@ -481,16 +479,6 @@ public class ReactiveElasticsearchTemplate extends AbstractReactiveElasticsearch
|
|||||||
return new ReactiveClusterTemplate(client.cluster(), converter);
|
return new ReactiveClusterTemplate(client.cluster(), converter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Flux<Suggest> suggest(SuggestBuilder suggestion, Class<?> entityType) {
|
|
||||||
throw new UnsupportedOperationException("not implemented");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Flux<Suggest> suggest(SuggestBuilder suggestion, IndexCoordinates index) {
|
|
||||||
throw new UnsupportedOperationException("not implemented");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Query matchAllQuery() {
|
public Query matchAllQuery() {
|
||||||
return NativeQuery.builder().withQuery(QueryBuilders.matchAllQueryAsQuery()).build();
|
return NativeQuery.builder().withQuery(QueryBuilders.matchAllQueryAsQuery()).build();
|
||||||
|
@ -454,7 +454,6 @@ public class ElasticsearchRestTemplate extends AbstractElasticsearchTemplate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public SearchResponse suggest(SuggestBuilder suggestion, IndexCoordinates index) {
|
public SearchResponse suggest(SuggestBuilder suggestion, IndexCoordinates index) {
|
||||||
SearchRequest searchRequest = requestFactory.searchRequest(suggestion, index);
|
SearchRequest searchRequest = requestFactory.searchRequest(suggestion, index);
|
||||||
return execute(client -> client.search(searchRequest, RequestOptions.DEFAULT));
|
return execute(client -> client.search(searchRequest, RequestOptions.DEFAULT));
|
||||||
@ -638,7 +637,6 @@ public class ElasticsearchRestTemplate extends AbstractElasticsearchTemplate {
|
|||||||
return Version.CURRENT.toString();
|
return Version.CURRENT.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public SearchResponse suggest(SuggestBuilder suggestion, Class<?> clazz) {
|
public SearchResponse suggest(SuggestBuilder suggestion, Class<?> clazz) {
|
||||||
return suggest(suggestion, getIndexCoordinatesFor(clazz));
|
return suggest(suggestion, getIndexCoordinatesFor(clazz));
|
||||||
|
@ -43,7 +43,6 @@ import org.elasticsearch.index.query.QueryBuilders;
|
|||||||
import org.elasticsearch.index.reindex.BulkByScrollResponse;
|
import org.elasticsearch.index.reindex.BulkByScrollResponse;
|
||||||
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
|
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
|
||||||
import org.elasticsearch.index.reindex.UpdateByQueryRequest;
|
import org.elasticsearch.index.reindex.UpdateByQueryRequest;
|
||||||
import org.elasticsearch.search.suggest.SuggestBuilder;
|
|
||||||
import org.reactivestreams.Publisher;
|
import org.reactivestreams.Publisher;
|
||||||
import org.springframework.data.elasticsearch.BulkFailureException;
|
import org.springframework.data.elasticsearch.BulkFailureException;
|
||||||
import org.springframework.data.elasticsearch.NoSuchIndexException;
|
import org.springframework.data.elasticsearch.NoSuchIndexException;
|
||||||
@ -557,26 +556,6 @@ public class ReactiveElasticsearchTemplate extends AbstractReactiveElasticsearch
|
|||||||
.onErrorResume(NoSuchIndexException.class, it -> Flux.empty()).map(ElasticsearchAggregation::new);
|
.onErrorResume(NoSuchIndexException.class, it -> Flux.empty()).map(ElasticsearchAggregation::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public Flux<org.elasticsearch.search.suggest.Suggest> suggest(SuggestBuilder suggestion, Class<?> entityType) {
|
|
||||||
return doSuggest(suggestion, getIndexCoordinatesFor(entityType));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public Flux<org.elasticsearch.search.suggest.Suggest> suggest(SuggestBuilder suggestion, IndexCoordinates index) {
|
|
||||||
return doSuggest(suggestion, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
private Flux<org.elasticsearch.search.suggest.Suggest> doSuggest(SuggestBuilder suggestion, IndexCoordinates index) {
|
|
||||||
return Flux.defer(() -> {
|
|
||||||
SearchRequest request = requestFactory.searchRequest(suggestion, index);
|
|
||||||
return Flux.from(execute(client -> client.suggest(request)));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Mono<Long> doCount(Query query, Class<?> entityType, IndexCoordinates index) {
|
protected Mono<Long> doCount(Query query, Class<?> entityType, IndexCoordinates index) {
|
||||||
return Mono.defer(() -> {
|
return Mono.defer(() -> {
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ import reactor.core.publisher.Mono;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.elasticsearch.search.suggest.SuggestBuilder;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
|
import org.springframework.data.elasticsearch.core.query.NativeSearchQuery;
|
||||||
@ -247,28 +246,6 @@ public interface ReactiveSearchOperations {
|
|||||||
*/
|
*/
|
||||||
Flux<? extends AggregationContainer<?>> aggregate(Query query, Class<?> entityType, IndexCoordinates index);
|
Flux<? extends AggregationContainer<?>> aggregate(Query query, Class<?> entityType, IndexCoordinates index);
|
||||||
|
|
||||||
/**
|
|
||||||
* Does a suggest query
|
|
||||||
*
|
|
||||||
* @param suggestion the query
|
|
||||||
* @param entityType must not be {@literal null}.
|
|
||||||
* @return the suggest response (Elasticsearch library classes)
|
|
||||||
* @deprecated since 4.3, use {@link #suggest(Query, Class)}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
Flux<org.elasticsearch.search.suggest.Suggest> suggest(SuggestBuilder suggestion, Class<?> entityType);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Does a suggest query
|
|
||||||
*
|
|
||||||
* @param suggestion the query
|
|
||||||
* @param index the index to run the query against
|
|
||||||
* @return the suggest response (Elasticsearch library classes)
|
|
||||||
* @deprecated since 4.3, use {@link #suggest(Query, Class, IndexCoordinates)}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
Flux<org.elasticsearch.search.suggest.Suggest> suggest(SuggestBuilder suggestion, IndexCoordinates index);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does a suggest query.
|
* Does a suggest query.
|
||||||
*
|
*
|
||||||
|
@ -17,12 +17,8 @@ package org.springframework.data.elasticsearch.core;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.elasticsearch.action.search.SearchResponse;
|
|
||||||
import org.elasticsearch.search.suggest.SuggestBuilder;
|
|
||||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
|
||||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||||
import org.springframework.data.elasticsearch.core.query.MoreLikeThisQuery;
|
import org.springframework.data.elasticsearch.core.query.MoreLikeThisQuery;
|
||||||
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
|
|
||||||
import org.springframework.data.elasticsearch.core.query.Query;
|
import org.springframework.data.elasticsearch.core.query.Query;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
|
|
||||||
@ -66,37 +62,6 @@ public interface SearchOperations {
|
|||||||
*/
|
*/
|
||||||
long count(Query query, @Nullable Class<?> clazz, IndexCoordinates index);
|
long count(Query query, @Nullable Class<?> clazz, IndexCoordinates index);
|
||||||
|
|
||||||
/**
|
|
||||||
* Does a suggest query
|
|
||||||
*
|
|
||||||
* @param suggestion the query
|
|
||||||
* @param clazz the entity class
|
|
||||||
* @return the suggest response
|
|
||||||
* @since 4.1
|
|
||||||
* @deprecated since 4.3 use a {@link NativeSearchQueryBuilder} with
|
|
||||||
* {@link NativeSearchQueryBuilder#withSuggestBuilder(SuggestBuilder)}, call {@link #search(Query, Class)}
|
|
||||||
* and get the suggest from {@link SearchHits#getSuggest()}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
default SearchResponse suggest(SuggestBuilder suggestion, Class<?> clazz) {
|
|
||||||
throw new InvalidDataAccessApiUsageException("Unsupported operation");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Does a suggest query
|
|
||||||
*
|
|
||||||
* @param suggestion the query
|
|
||||||
* @param index the index to run the query against
|
|
||||||
* @return the suggest response
|
|
||||||
* @deprecated since 4.3 use a {@link NativeSearchQueryBuilder} with
|
|
||||||
* {@link NativeSearchQueryBuilder#withSuggestBuilder(SuggestBuilder)}, call {@link #search(Query, Class)}
|
|
||||||
* and get the suggest from {@link SearchHits#getSuggest()}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
default SearchResponse suggest(SuggestBuilder suggestion, IndexCoordinates index) {
|
|
||||||
throw new InvalidDataAccessApiUsageException("Unsupported operation");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the query against elasticsearch and return the first returned object.
|
* Execute the query against elasticsearch and return the first returned object.
|
||||||
*
|
*
|
||||||
|
@ -40,8 +40,8 @@ import org.springframework.data.annotation.Id;
|
|||||||
import org.springframework.data.elasticsearch.annotations.CompletionContext;
|
import org.springframework.data.elasticsearch.annotations.CompletionContext;
|
||||||
import org.springframework.data.elasticsearch.annotations.CompletionField;
|
import org.springframework.data.elasticsearch.annotations.CompletionField;
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
import org.springframework.data.elasticsearch.core.AbstractElasticsearchTemplate;
|
|
||||||
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
|
||||||
|
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
|
||||||
import org.springframework.data.elasticsearch.core.IndexOperations;
|
import org.springframework.data.elasticsearch.core.IndexOperations;
|
||||||
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates;
|
||||||
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
||||||
@ -124,7 +124,7 @@ public abstract class CompletionWithContextsIntegrationTests {
|
|||||||
((CompletionSuggestionBuilder) completionSuggestionFuzzyBuilder).contexts(contextMap);
|
((CompletionSuggestionBuilder) completionSuggestionFuzzyBuilder).contexts(contextMap);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
SearchResponse suggestResponse = ((AbstractElasticsearchTemplate) operations).suggest(
|
SearchResponse suggestResponse = ((ElasticsearchRestTemplate) operations).suggest(
|
||||||
new SuggestBuilder().addSuggestion("test-suggest", completionSuggestionFuzzyBuilder),
|
new SuggestBuilder().addSuggestion("test-suggest", completionSuggestionFuzzyBuilder),
|
||||||
IndexCoordinates.of("test-index-context-completion"));
|
IndexCoordinates.of("test-index-context-completion"));
|
||||||
assertThat(suggestResponse.getSuggest()).isNotNull();
|
assertThat(suggestResponse.getSuggest()).isNotNull();
|
||||||
@ -156,7 +156,7 @@ public abstract class CompletionWithContextsIntegrationTests {
|
|||||||
((CompletionSuggestionBuilder) completionSuggestionFuzzyBuilder).contexts(contextMap);
|
((CompletionSuggestionBuilder) completionSuggestionFuzzyBuilder).contexts(contextMap);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
SearchResponse suggestResponse = ((AbstractElasticsearchTemplate) operations).suggest(
|
SearchResponse suggestResponse = ((ElasticsearchRestTemplate) operations).suggest(
|
||||||
new SuggestBuilder().addSuggestion("test-suggest", completionSuggestionFuzzyBuilder),
|
new SuggestBuilder().addSuggestion("test-suggest", completionSuggestionFuzzyBuilder),
|
||||||
IndexCoordinates.of("test-index-context-completion"));
|
IndexCoordinates.of("test-index-context-completion"));
|
||||||
assertThat(suggestResponse.getSuggest()).isNotNull();
|
assertThat(suggestResponse.getSuggest()).isNotNull();
|
||||||
@ -188,7 +188,7 @@ public abstract class CompletionWithContextsIntegrationTests {
|
|||||||
((CompletionSuggestionBuilder) completionSuggestionFuzzyBuilder).contexts(contextMap);
|
((CompletionSuggestionBuilder) completionSuggestionFuzzyBuilder).contexts(contextMap);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
SearchResponse suggestResponse = ((AbstractElasticsearchTemplate) operations).suggest(
|
SearchResponse suggestResponse = ((ElasticsearchRestTemplate) operations).suggest(
|
||||||
new SuggestBuilder().addSuggestion("test-suggest", completionSuggestionFuzzyBuilder),
|
new SuggestBuilder().addSuggestion("test-suggest", completionSuggestionFuzzyBuilder),
|
||||||
IndexCoordinates.of("test-index-context-completion"));
|
IndexCoordinates.of("test-index-context-completion"));
|
||||||
assertThat(suggestResponse.getSuggest()).isNotNull();
|
assertThat(suggestResponse.getSuggest()).isNotNull();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user