15
15
*/
16
16
package org .springframework .data .elasticsearch .core ;
17
17
18
- import static org .apache .commons .collections . CollectionUtils . isNotEmpty ;
19
- import static org .apache .commons .lang .StringUtils .* ;
18
+ import static org .apache .commons .lang . StringUtils . isNotBlank ;
19
+ import static org .apache .commons .lang .StringUtils .isBlank ;
20
20
import static org .elasticsearch .action .search .SearchType .*;
21
21
import static org .elasticsearch .client .Requests .*;
22
22
import static org .elasticsearch .cluster .metadata .AliasAction .Type .*;
23
23
import static org .elasticsearch .index .VersionType .*;
24
24
import static org .elasticsearch .index .query .QueryBuilders .*;
25
25
import static org .springframework .data .elasticsearch .core .MappingBuilder .*;
26
+ import static org .springframework .util .CollectionUtils .isEmpty ;
26
27
27
28
import java .io .BufferedReader ;
28
29
import java .io .IOException ;
29
30
import java .io .InputStreamReader ;
30
31
import java .lang .reflect .Method ;
31
32
import java .util .*;
32
33
33
- import org .apache .commons .collections .CollectionUtils ;
34
34
import org .elasticsearch .action .ListenableActionFuture ;
35
35
import org .elasticsearch .action .admin .indices .alias .get .GetAliasesRequest ;
36
36
import org .elasticsearch .action .admin .indices .create .CreateIndexRequestBuilder ;
@@ -465,8 +465,8 @@ private long doCount(SearchRequestBuilder searchRequestBuilder, QueryBuilder ela
465
465
}
466
466
467
467
private <T > CountRequestBuilder prepareCount (Query query , Class <T > clazz ) {
468
- String indexName [] = isNotEmpty (query .getIndices ()) ? query .getIndices ().toArray (new String [query .getIndices ().size ()]) : retrieveIndexNameFromPersistentEntity (clazz );
469
- String types [] = isNotEmpty (query .getTypes ()) ? query .getTypes ().toArray (new String [query .getTypes ().size ()]) : retrieveTypeFromPersistentEntity (clazz );
468
+ String indexName [] = ! isEmpty (query .getIndices ()) ? query .getIndices ().toArray (new String [query .getIndices ().size ()]) : retrieveIndexNameFromPersistentEntity (clazz );
469
+ String types [] = ! isEmpty (query .getTypes ()) ? query .getTypes ().toArray (new String [query .getTypes ().size ()]) : retrieveTypeFromPersistentEntity (clazz );
470
470
471
471
Assert .notNull (indexName , "No index defined for Query" );
472
472
@@ -485,8 +485,8 @@ public <T> LinkedList<T> multiGet(SearchQuery searchQuery, Class<T> clazz) {
485
485
486
486
private <T > MultiGetResponse getMultiResponse (Query searchQuery , Class <T > clazz ) {
487
487
488
- String indexName = isNotEmpty (searchQuery .getIndices ()) ? searchQuery .getIndices ().get (0 ) : getPersistentEntityFor (clazz ).getIndexName ();
489
- String type = isNotEmpty (searchQuery .getTypes ()) ? searchQuery .getTypes ().get (0 ) : getPersistentEntityFor (clazz ).getIndexType ();
488
+ String indexName = ! isEmpty (searchQuery .getIndices ()) ? searchQuery .getIndices ().get (0 ) : getPersistentEntityFor (clazz ).getIndexName ();
489
+ String type = ! isEmpty (searchQuery .getTypes ()) ? searchQuery .getTypes ().get (0 ) : getPersistentEntityFor (clazz ).getIndexType ();
490
490
491
491
Assert .notNull (indexName , "No index defined for Query" );
492
492
Assert .notNull (type , "No type define for Query" );
@@ -735,7 +735,7 @@ private SearchRequestBuilder prepareScan(Query query, long scrollTimeInMillis, b
735
735
.setScroll (TimeValue .timeValueMillis (scrollTimeInMillis )).setFrom (0 )
736
736
.setSize (query .getPageable ().getPageSize ());
737
737
738
- if (isNotEmpty (query .getFields ())) {
738
+ if (! isEmpty (query .getFields ())) {
739
739
requestBuilder .addFields (toArray (query .getFields ()));
740
740
}
741
741
@@ -817,7 +817,7 @@ public <T> Page<T> moreLikeThis(MoreLikeThisQuery query, Class<T> clazz) {
817
817
if (query .getMaxQueryTerms () != null ) {
818
818
moreLikeThisQueryBuilder .maxQueryTerms (query .getMaxQueryTerms ());
819
819
}
820
- if (isNotEmpty (query .getStopWords ())) {
820
+ if (! isEmpty (query .getStopWords ())) {
821
821
moreLikeThisQueryBuilder .stopWords (toArray (query .getStopWords ()));
822
822
}
823
823
if (query .getMinDocFreq () != null ) {
@@ -844,7 +844,7 @@ private SearchResponse doSearch(SearchRequestBuilder searchRequest, SearchQuery
844
844
searchRequest .setPostFilter (searchQuery .getFilter ());
845
845
}
846
846
847
- if (CollectionUtils . isNotEmpty (searchQuery .getElasticsearchSorts ())) {
847
+ if (! isEmpty (searchQuery .getElasticsearchSorts ())) {
848
848
for (SortBuilder sort : searchQuery .getElasticsearchSorts ()) {
849
849
searchRequest .addSort (sort );
850
850
}
@@ -863,13 +863,13 @@ private SearchResponse doSearch(SearchRequestBuilder searchRequest, SearchQuery
863
863
}
864
864
}
865
865
866
- if (CollectionUtils . isNotEmpty (searchQuery .getIndicesBoost ())) {
866
+ if (! isEmpty (searchQuery .getIndicesBoost ())) {
867
867
for (IndexBoost indexBoost : searchQuery .getIndicesBoost ()) {
868
868
searchRequest .addIndexBoost (indexBoost .getIndexName (), indexBoost .getBoost ());
869
869
}
870
870
}
871
871
872
- if (CollectionUtils . isNotEmpty (searchQuery .getAggregations ())) {
872
+ if (! isEmpty (searchQuery .getAggregations ())) {
873
873
for (AbstractAggregationBuilder aggregationBuilder : searchQuery .getAggregations ()) {
874
874
searchRequest .addAggregation (aggregationBuilder );
875
875
}
0 commit comments