mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-22 12:02:10 +00:00
DATAES-328 - Replace explicit generics with diamond operator.
This commit is contained in:
parent
0cada7f374
commit
4c7dd4939a
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors.
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -45,7 +45,7 @@ class CriteriaFilterProcessor {
|
||||
|
||||
|
||||
QueryBuilder createFilterFromCriteria(Criteria criteria) {
|
||||
List<QueryBuilder> fbList = new LinkedList<QueryBuilder>();
|
||||
List<QueryBuilder> fbList = new LinkedList<>();
|
||||
QueryBuilder filter = null;
|
||||
|
||||
ListIterator<Criteria> chainIterator = criteria.getCriteriaChain().listIterator();
|
||||
@ -86,7 +86,7 @@ class CriteriaFilterProcessor {
|
||||
|
||||
private List<QueryBuilder> createFilterFragmentForCriteria(Criteria chainedCriteria) {
|
||||
Iterator<Criteria.CriteriaEntry> it = chainedCriteria.getFilterCriteriaEntries().iterator();
|
||||
List<QueryBuilder> filterList = new LinkedList<QueryBuilder>();
|
||||
List<QueryBuilder> filterList = new LinkedList<>();
|
||||
|
||||
String fieldName = chainedCriteria.getField().getName();
|
||||
Assert.notNull(fieldName, "Unknown field");
|
||||
@ -235,7 +235,7 @@ class CriteriaFilterProcessor {
|
||||
}
|
||||
|
||||
private List<QueryBuilder> buildNegationFilter(String fieldName, Iterator<Criteria.CriteriaEntry> it) {
|
||||
List<QueryBuilder> notFilterList = new LinkedList<QueryBuilder>();
|
||||
List<QueryBuilder> notFilterList = new LinkedList<>();
|
||||
|
||||
while (it.hasNext()) {
|
||||
Criteria.CriteriaEntry criteriaEntry = it.next();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -46,9 +46,9 @@ class CriteriaQueryProcessor {
|
||||
if (criteria == null)
|
||||
return null;
|
||||
|
||||
List<QueryBuilder> shouldQueryBuilderList = new LinkedList<QueryBuilder>();
|
||||
List<QueryBuilder> mustNotQueryBuilderList = new LinkedList<QueryBuilder>();
|
||||
List<QueryBuilder> mustQueryBuilderList = new LinkedList<QueryBuilder>();
|
||||
List<QueryBuilder> shouldQueryBuilderList = new LinkedList<>();
|
||||
List<QueryBuilder> mustNotQueryBuilderList = new LinkedList<>();
|
||||
List<QueryBuilder> mustQueryBuilderList = new LinkedList<>();
|
||||
|
||||
ListIterator<Criteria> chainIterator = criteria.getCriteriaChain().listIterator();
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class DefaultResultMapper extends AbstractResultMapper {
|
||||
@Override
|
||||
public <T> AggregatedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable) {
|
||||
long totalHits = response.getHits().totalHits();
|
||||
List<T> results = new ArrayList<T>();
|
||||
List<T> results = new ArrayList<>();
|
||||
for (SearchHit hit : response.getHits()) {
|
||||
if (hit != null) {
|
||||
T result = null;
|
||||
@ -94,7 +94,7 @@ public class DefaultResultMapper extends AbstractResultMapper {
|
||||
}
|
||||
}
|
||||
|
||||
return new AggregatedPageImpl<T>(results, pageable, totalHits, response.getAggregations());
|
||||
return new AggregatedPageImpl<>(results, pageable, totalHits, response.getAggregations());
|
||||
}
|
||||
|
||||
private <T> void populateScriptFields(T result, SearchHit hit) {
|
||||
@ -160,7 +160,7 @@ public class DefaultResultMapper extends AbstractResultMapper {
|
||||
|
||||
@Override
|
||||
public <T> LinkedList<T> mapResults(MultiGetResponse responses, Class<T> clazz) {
|
||||
LinkedList<T> list = new LinkedList<T>();
|
||||
LinkedList<T> list = new LinkedList<>();
|
||||
for (MultiGetItemResponse response : responses.getResponses()) {
|
||||
if (!response.isFailed() && response.getResponse().isExists()) {
|
||||
T result = mapEntity(response.getResponse().getSourceAsString(), clazz);
|
||||
|
@ -604,7 +604,7 @@ public class ElasticsearchTemplate implements ElasticsearchOperations, Applicati
|
||||
}
|
||||
BulkResponse bulkResponse = bulkRequest.execute().actionGet();
|
||||
if (bulkResponse.hasFailures()) {
|
||||
Map<String, String> failedDocuments = new HashMap<String, String>();
|
||||
Map<String, String> failedDocuments = new HashMap<>();
|
||||
for (BulkItemResponse item : bulkResponse.getItems()) {
|
||||
if (item.isFailed())
|
||||
failedDocuments.put(item.getId(), item.getFailureMessage());
|
||||
@ -624,7 +624,7 @@ public class ElasticsearchTemplate implements ElasticsearchOperations, Applicati
|
||||
}
|
||||
BulkResponse bulkResponse = bulkRequest.execute().actionGet();
|
||||
if (bulkResponse.hasFailures()) {
|
||||
Map<String, String> failedDocuments = new HashMap<String, String>();
|
||||
Map<String, String> failedDocuments = new HashMap<>();
|
||||
for (BulkItemResponse item : bulkResponse.getItems()) {
|
||||
if (item.isFailed())
|
||||
failedDocuments.put(item.getId(), item.getFailureMessage());
|
||||
@ -694,19 +694,19 @@ public class ElasticsearchTemplate implements ElasticsearchOperations, Applicati
|
||||
String scrollId = scan(searchQuery, scrollTimeInMillis, true);
|
||||
|
||||
BulkRequestBuilder bulkRequestBuilder = client.prepareBulk();
|
||||
List<String> ids = new ArrayList<String>();
|
||||
List<String> ids = new ArrayList<>();
|
||||
boolean hasRecords = true;
|
||||
while (hasRecords) {
|
||||
Page<String> page = scroll(scrollId, scrollTimeInMillis, new SearchResultMapper() {
|
||||
@Override
|
||||
public <T> AggregatedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
List<String> result = new ArrayList<>();
|
||||
for (SearchHit searchHit : response.getHits()) {
|
||||
String id = searchHit.getId();
|
||||
result.add(id);
|
||||
}
|
||||
if (result.size() > 0) {
|
||||
return new AggregatedPageImpl<T>((List<T>) result);
|
||||
return new AggregatedPageImpl<>((List<T>) result);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1169,7 +1169,7 @@ public class ElasticsearchTemplate implements ElasticsearchOperations, Applicati
|
||||
}
|
||||
|
||||
private List<String> extractIds(SearchResponse response) {
|
||||
List<String> ids = new ArrayList<String>();
|
||||
List<String> ids = new ArrayList<>();
|
||||
for (SearchHit hit : response.getHits()) {
|
||||
if (hit != null) {
|
||||
ids.add(hit.getId());
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -47,7 +47,7 @@ import org.springframework.data.elasticsearch.core.facet.result.*;
|
||||
public abstract class FacetedPageImpl<T> extends PageImpl<T> implements FacetedPage<T>, AggregatedPage<T> {
|
||||
|
||||
private List<FacetResult> facets;
|
||||
private Map<String, FacetResult> mapOfFacets = new HashMap<String, FacetResult>();
|
||||
private Map<String, FacetResult> mapOfFacets = new HashMap<>();
|
||||
|
||||
public FacetedPageImpl(List<T> content) {
|
||||
super(content);
|
||||
@ -85,10 +85,10 @@ public abstract class FacetedPageImpl<T> extends PageImpl<T> implements FacetedP
|
||||
*/
|
||||
private void processAggregations() {
|
||||
if (facets == null) {
|
||||
facets = new ArrayList<FacetResult>();
|
||||
facets = new ArrayList<>();
|
||||
for (Aggregation agg : getAggregations()) {
|
||||
if (agg instanceof Terms) {
|
||||
List<Term> terms = new ArrayList<Term>();
|
||||
List<Term> terms = new ArrayList<>();
|
||||
for (Terms.Bucket t : ((Terms) agg).getBuckets()) {
|
||||
terms.add(new Term(t.getKeyAsString(), t.getDocCount()));
|
||||
}
|
||||
@ -96,7 +96,7 @@ public abstract class FacetedPageImpl<T> extends PageImpl<T> implements FacetedP
|
||||
}
|
||||
if (agg instanceof Range) {
|
||||
List<? extends Range.Bucket> buckets = ((Range) agg).getBuckets();
|
||||
List<org.springframework.data.elasticsearch.core.facet.result.Range> ranges = new ArrayList<org.springframework.data.elasticsearch.core.facet.result.Range>();
|
||||
List<org.springframework.data.elasticsearch.core.facet.result.Range> ranges = new ArrayList<>();
|
||||
for (Range.Bucket b : buckets) {
|
||||
ExtendedStats rStats = (ExtendedStats) b.getAggregations().get(AbstractFacetRequest.INTERNAL_STATS);
|
||||
if (rStats != null) {
|
||||
@ -113,7 +113,7 @@ public abstract class FacetedPageImpl<T> extends PageImpl<T> implements FacetedP
|
||||
addFacet(new StatisticalResult(agg.getName(), stats.getCount(), stats.getMax(), stats.getMin(), stats.getAvg(), stats.getStdDeviation(), stats.getSumOfSquares(), stats.getSum(), stats.getVariance()));
|
||||
}
|
||||
if (agg instanceof Histogram) {
|
||||
List<IntervalUnit> intervals = new ArrayList<IntervalUnit>();
|
||||
List<IntervalUnit> intervals = new ArrayList<>();
|
||||
for (Histogram.Bucket h : ((Histogram) agg).getBuckets()) {
|
||||
ExtendedStats hStats = (ExtendedStats) h.getAggregations().get(AbstractFacetRequest.INTERNAL_STATS);
|
||||
if (hStats != null) {
|
||||
|
@ -167,7 +167,7 @@ class MappingBuilder {
|
||||
|
||||
private static java.lang.reflect.Field[] retrieveFields(Class clazz) {
|
||||
// Create list of fields.
|
||||
List<java.lang.reflect.Field> fields = new ArrayList<java.lang.reflect.Field>();
|
||||
List<java.lang.reflect.Field> fields = new ArrayList<>();
|
||||
|
||||
// Keep backing up the inheritance hierarchy.
|
||||
Class targetClass = clazz;
|
||||
|
@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.core.aggregation.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -18,7 +33,7 @@ import org.springframework.data.elasticsearch.core.aggregation.AggregatedPage;
|
||||
public class AggregatedPageImpl<T> extends FacetedPageImpl<T> implements AggregatedPage<T> {
|
||||
|
||||
private Aggregations aggregations;
|
||||
private Map<String, Aggregation> mapOfAggregations = new HashMap<String, Aggregation>();
|
||||
private Map<String, Aggregation> mapOfAggregations = new HashMap<>();
|
||||
|
||||
public AggregatedPageImpl(List<T> content) {
|
||||
super(content);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -41,7 +41,7 @@ public class RangeFacetRequest extends AbstractFacetRequest {
|
||||
private String keyField;
|
||||
private String valueField;
|
||||
|
||||
private List<Entry> entries = new ArrayList<Entry>();
|
||||
private List<Entry> entries = new ArrayList<>();
|
||||
|
||||
public RangeFacetRequest(String name) {
|
||||
super(name);
|
||||
|
@ -37,7 +37,7 @@ public class SimpleElasticsearchMappingContext extends
|
||||
|
||||
@Override
|
||||
protected <T> SimpleElasticsearchPersistentEntity<?> createPersistentEntity(TypeInformation<T> typeInformation) {
|
||||
final SimpleElasticsearchPersistentEntity<T> persistentEntity = new SimpleElasticsearchPersistentEntity<T>(
|
||||
final SimpleElasticsearchPersistentEntity<T> persistentEntity = new SimpleElasticsearchPersistentEntity<>(
|
||||
typeInformation);
|
||||
if (context != null) {
|
||||
persistentEntity.setApplicationContext(context);
|
||||
|
@ -34,8 +34,8 @@ import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||
public class SimpleElasticsearchPersistentProperty extends
|
||||
AnnotationBasedPersistentProperty<ElasticsearchPersistentProperty> implements ElasticsearchPersistentProperty {
|
||||
|
||||
private static final Set<Class<?>> SUPPORTED_ID_TYPES = new HashSet<Class<?>>();
|
||||
private static final Set<String> SUPPORTED_ID_PROPERTY_NAMES = new HashSet<String>();
|
||||
private static final Set<Class<?>> SUPPORTED_ID_TYPES = new HashSet<>();
|
||||
private static final Set<String> SUPPORTED_ID_PROPERTY_NAMES = new HashSet<>();
|
||||
|
||||
static {
|
||||
SUPPORTED_ID_TYPES.add(String.class);
|
||||
|
@ -35,9 +35,9 @@ abstract class AbstractQuery implements Query {
|
||||
|
||||
protected Pageable pageable = DEFAULT_PAGE;
|
||||
protected Sort sort;
|
||||
protected List<String> indices = new ArrayList<String>();
|
||||
protected List<String> types = new ArrayList<String>();
|
||||
protected List<String> fields = new ArrayList<String>();
|
||||
protected List<String> indices = new ArrayList<>();
|
||||
protected List<String> types = new ArrayList<>();
|
||||
protected List<String> fields = new ArrayList<>();
|
||||
protected SourceFilter sourceFilter;
|
||||
protected float minScore;
|
||||
protected Collection<String> ids;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 the original author or authors.
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -57,11 +57,11 @@ public class Criteria {
|
||||
private float boost = Float.NaN;
|
||||
private boolean negating = false;
|
||||
|
||||
private List<Criteria> criteriaChain = new ArrayList<Criteria>(1);
|
||||
private List<Criteria> criteriaChain = new ArrayList<>(1);
|
||||
|
||||
private Set<CriteriaEntry> queryCriteria = new LinkedHashSet<CriteriaEntry>();
|
||||
private Set<CriteriaEntry> queryCriteria = new LinkedHashSet<>();
|
||||
|
||||
private Set<CriteriaEntry> filterCriteria = new LinkedHashSet<CriteriaEntry>();
|
||||
private Set<CriteriaEntry> filterCriteria = new LinkedHashSet<>();
|
||||
|
||||
public Criteria() {
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors.
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -29,20 +29,19 @@ import org.springframework.data.domain.Pageable;
|
||||
* @author Rizwan Idrees
|
||||
* @author Mohsin Husen
|
||||
*/
|
||||
|
||||
public class MoreLikeThisQuery {
|
||||
|
||||
private String id;
|
||||
private String indexName;
|
||||
private String type;
|
||||
private List<String> searchIndices = new ArrayList<String>();
|
||||
private List<String> searchTypes = new ArrayList<String>();
|
||||
private List<String> fields = new ArrayList<String>();
|
||||
private List<String> searchIndices = new ArrayList<>();
|
||||
private List<String> searchTypes = new ArrayList<>();
|
||||
private List<String> fields = new ArrayList<>();
|
||||
private String routing;
|
||||
private Float percentTermsToMatch;
|
||||
private Integer minTermFreq;
|
||||
private Integer maxQueryTerms;
|
||||
private List<String> stopWords = new ArrayList<String>();
|
||||
private List<String> stopWords = new ArrayList<>();
|
||||
private Integer minDocFreq;
|
||||
private Integer maxDocFreq;
|
||||
private Integer minWordLen;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors.
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -38,7 +38,7 @@ public class NativeSearchQuery extends AbstractQuery implements SearchQuery {
|
||||
private QueryBuilder query;
|
||||
private QueryBuilder filter;
|
||||
private List<SortBuilder> sorts;
|
||||
private final List<ScriptField> scriptFields = new ArrayList<ScriptField>();
|
||||
private final List<ScriptField> scriptFields = new ArrayList<>();
|
||||
private List<FacetRequest> facets;
|
||||
private List<AbstractAggregationBuilder> aggregations;
|
||||
private HighlightBuilder.Field[] highlightFields;
|
||||
@ -97,7 +97,7 @@ public class NativeSearchQuery extends AbstractQuery implements SearchQuery {
|
||||
|
||||
public void addFacet(FacetRequest facetRequest) {
|
||||
if (facets == null) {
|
||||
facets = new ArrayList<FacetRequest>();
|
||||
facets = new ArrayList<>();
|
||||
}
|
||||
facets.add(facetRequest);
|
||||
}
|
||||
@ -119,7 +119,7 @@ public class NativeSearchQuery extends AbstractQuery implements SearchQuery {
|
||||
|
||||
public void addAggregation(AbstractAggregationBuilder aggregationBuilder) {
|
||||
if (aggregations == null) {
|
||||
aggregations = new ArrayList<AbstractAggregationBuilder>();
|
||||
aggregations = new ArrayList<>();
|
||||
}
|
||||
aggregations.add(aggregationBuilder);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors.
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -34,15 +34,14 @@ import org.springframework.data.elasticsearch.core.facet.FacetRequest;
|
||||
* @author Mohsin Husen
|
||||
* @author Artur Konczak
|
||||
*/
|
||||
|
||||
public class NativeSearchQueryBuilder {
|
||||
|
||||
private QueryBuilder queryBuilder;
|
||||
private QueryBuilder filterBuilder;
|
||||
private List<ScriptField> scriptFields = new ArrayList<ScriptField>();
|
||||
private List<SortBuilder> sortBuilders = new ArrayList<SortBuilder>();
|
||||
private List<FacetRequest> facetRequests = new ArrayList<FacetRequest>();
|
||||
private List<AbstractAggregationBuilder> aggregationBuilders = new ArrayList<AbstractAggregationBuilder>();
|
||||
private List<ScriptField> scriptFields = new ArrayList<>();
|
||||
private List<SortBuilder> sortBuilders = new ArrayList<>();
|
||||
private List<FacetRequest> facetRequests = new ArrayList<>();
|
||||
private List<AbstractAggregationBuilder> aggregationBuilders = new ArrayList<>();
|
||||
private HighlightBuilder.Field[] highlightFields;
|
||||
private Pageable pageable;
|
||||
private String[] indices;
|
||||
|
@ -44,7 +44,7 @@ import org.springframework.data.repository.cdi.CdiRepositoryExtensionSupport;
|
||||
*/
|
||||
public class ElasticsearchRepositoryExtension extends CdiRepositoryExtensionSupport {
|
||||
|
||||
private final Map<Set<Annotation>, Bean<ElasticsearchOperations>> elasticsearchOperationsMap = new HashMap<Set<Annotation>, Bean<ElasticsearchOperations>>();
|
||||
private final Map<Set<Annotation>, Bean<ElasticsearchOperations>> elasticsearchOperationsMap = new HashMap<>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
<T> void processBean(@Observes ProcessBean<T> processBean) {
|
||||
@ -78,7 +78,7 @@ public class ElasticsearchRepositoryExtension extends CdiRepositoryExtensionSupp
|
||||
ElasticsearchOperations.class.getName(), qualifiers));
|
||||
}
|
||||
|
||||
return new ElasticsearchRepositoryBean<T>(elasticsearchOperationsBean, qualifiers, repositoryType, beanManager,
|
||||
return new ElasticsearchRepositoryBean<>(elasticsearchOperationsBean, qualifiers, repositoryType, beanManager,
|
||||
Optional.ofNullable(getCustomImplementationDetector()));
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public abstract class AbstractElasticsearchRepository<T, ID extends Serializable
|
||||
public Iterable<T> findAll() {
|
||||
int itemCount = (int) this.count();
|
||||
if (itemCount == 0) {
|
||||
return new PageImpl<T>(Collections.<T> emptyList());
|
||||
return new PageImpl<>(Collections.<T>emptyList());
|
||||
}
|
||||
return this.findAll(new PageRequest(0, Math.max(1, itemCount)));
|
||||
}
|
||||
@ -119,7 +119,7 @@ public abstract class AbstractElasticsearchRepository<T, ID extends Serializable
|
||||
public Iterable<T> findAll(Sort sort) {
|
||||
int itemCount = (int) this.count();
|
||||
if (itemCount == 0) {
|
||||
return new PageImpl<T>(Collections.<T> emptyList());
|
||||
return new PageImpl<>(Collections.<T>emptyList());
|
||||
}
|
||||
SearchQuery query = new NativeSearchQueryBuilder().withQuery(matchAllQuery())
|
||||
.withPageable(new PageRequest(0, itemCount, sort)).build();
|
||||
@ -150,7 +150,7 @@ public abstract class AbstractElasticsearchRepository<T, ID extends Serializable
|
||||
public <S extends T> List<S> save(List<S> entities) {
|
||||
Assert.notNull(entities, "Cannot insert 'null' as a List.");
|
||||
Assert.notEmpty(entities, "Cannot insert empty List.");
|
||||
List<IndexQuery> queries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> queries = new ArrayList<>();
|
||||
for (S s : entities) {
|
||||
queries.add(createIndexQuery(s));
|
||||
}
|
||||
@ -167,7 +167,7 @@ public abstract class AbstractElasticsearchRepository<T, ID extends Serializable
|
||||
@Override
|
||||
public <S extends T> Iterable<S> save(Iterable<S> entities) {
|
||||
Assert.notNull(entities, "Cannot insert 'null' as a List.");
|
||||
List<IndexQuery> queries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> queries = new ArrayList<>();
|
||||
for (S s : entities) {
|
||||
queries.add(createIndexQuery(s));
|
||||
}
|
||||
@ -186,7 +186,7 @@ public abstract class AbstractElasticsearchRepository<T, ID extends Serializable
|
||||
SearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(query).build();
|
||||
int count = (int) elasticsearchOperations.count(searchQuery, getEntityClass());
|
||||
if (count == 0) {
|
||||
return new PageImpl<T>(Collections.<T> emptyList());
|
||||
return new PageImpl<>(Collections.<T>emptyList());
|
||||
}
|
||||
searchQuery.setPageable(new PageRequest(0, count));
|
||||
return elasticsearchOperations.queryForPage(searchQuery, getEntityClass());
|
||||
@ -311,7 +311,7 @@ public abstract class AbstractElasticsearchRepository<T, ID extends Serializable
|
||||
|
||||
private List<String> stringIdsRepresentation(Iterable<ID> ids) {
|
||||
Assert.notNull(ids, "ids can't be null.");
|
||||
List<String> stringIds = new ArrayList<String>();
|
||||
List<String> stringIds = new ArrayList<>();
|
||||
for (ID id : ids) {
|
||||
stringIds.add(stringIdRepresentation(id));
|
||||
}
|
||||
|
@ -52,6 +52,6 @@ public class ElasticsearchEntityInformationCreatorImpl implements ElasticsearchE
|
||||
Assert.notNull(persistentEntity, String.format("Unable to obtain mapping metadata for %s!", domainClass));
|
||||
Assert.notNull(persistentEntity.getIdProperty(), String.format("No id property found for %s!", domainClass));
|
||||
|
||||
return new MappingElasticsearchEntityInformation<T, ID>(persistentEntity);
|
||||
return new MappingElasticsearchEntityInformation<>(persistentEntity);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors.
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -84,7 +84,7 @@ public class NestedObjectTests {
|
||||
@Test
|
||||
public void shouldIndexInitialLevelNestedObject() {
|
||||
|
||||
final List<Car> cars = new ArrayList<Car>();
|
||||
final List<Car> cars = new ArrayList<>();
|
||||
|
||||
final Car saturn = new Car();
|
||||
saturn.setName("Saturn");
|
||||
@ -116,7 +116,7 @@ public class NestedObjectTests {
|
||||
bar.setName("Bar");
|
||||
bar.setCar(Arrays.asList(car));
|
||||
|
||||
final List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
final List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
final IndexQuery indexQuery1 = new IndexQuery();
|
||||
indexQuery1.setId(foo.getId());
|
||||
indexQuery1.setObject(foo);
|
||||
@ -253,7 +253,7 @@ public class NestedObjectTests {
|
||||
indexQuery2.setId(person2.getId());
|
||||
indexQuery2.setObject(person2);
|
||||
|
||||
final List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
final List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
indexQueries.add(indexQuery1);
|
||||
indexQueries.add(indexQuery2);
|
||||
|
||||
@ -263,7 +263,7 @@ public class NestedObjectTests {
|
||||
@Test
|
||||
public void shouldSearchBooksForPersonInitialLevelNestedType() {
|
||||
|
||||
final List<Car> cars = new ArrayList<Car>();
|
||||
final List<Car> cars = new ArrayList<>();
|
||||
|
||||
final Car saturn = new Car();
|
||||
saturn.setName("Saturn");
|
||||
@ -312,7 +312,7 @@ public class NestedObjectTests {
|
||||
bar.setName("Bar");
|
||||
bar.setCar(Arrays.asList(car));
|
||||
|
||||
final List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
final List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
final IndexQuery indexQuery1 = new IndexQuery();
|
||||
indexQuery1.setId(foo.getId());
|
||||
indexQuery1.setObject(foo);
|
||||
@ -351,16 +351,16 @@ public class NestedObjectTests {
|
||||
book2.setId(randomNumeric(5));
|
||||
book2.setName("testBook2");
|
||||
|
||||
final Map<Integer, Collection<String>> map1 = new HashMap<Integer, Collection<String>>();
|
||||
final Map<Integer, Collection<String>> map1 = new HashMap<>();
|
||||
map1.put(1, Arrays.asList("test1", "test2"));
|
||||
|
||||
final Map<Integer, Collection<String>> map2 = new HashMap<Integer, Collection<String>>();
|
||||
final Map<Integer, Collection<String>> map2 = new HashMap<>();
|
||||
map2.put(1, Arrays.asList("test3", "test4"));
|
||||
|
||||
book1.setBuckets(map1);
|
||||
book2.setBuckets(map2);
|
||||
|
||||
final List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
final List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
final IndexQuery indexQuery1 = new IndexQuery();
|
||||
indexQuery1.setId(book1.getId());
|
||||
indexQuery1.setObject(book1);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -48,7 +48,7 @@ public class AliasTests {
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
Map<String, Object> settings = new HashMap<String, Object>();
|
||||
Map<String, Object> settings = new HashMap<>();
|
||||
settings.put("index.refresh_interval", "-1");
|
||||
settings.put("index.number_of_replicas", "0");
|
||||
settings.put("index.number_of_shards", "2");
|
||||
|
@ -187,7 +187,7 @@ public class DefaultResultMapperTests {
|
||||
}
|
||||
|
||||
private Map<String, SearchHitField> createCarFields(String name, String model) {
|
||||
Map<String, SearchHitField> result = new HashMap<String, SearchHitField>();
|
||||
Map<String, SearchHitField> result = new HashMap<>();
|
||||
result.put("name", new InternalSearchHitField("name", Arrays.<Object>asList(name)));
|
||||
result.put("model", new InternalSearchHitField("model", Arrays.<Object>asList(model)));
|
||||
return result;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2016 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -142,7 +142,7 @@ public class ElasticsearchTemplateTests {
|
||||
@Test
|
||||
public void shouldReturnObjectsForGivenIdsUsingMultiGet() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId).message("some message")
|
||||
@ -170,7 +170,7 @@ public class ElasticsearchTemplateTests {
|
||||
@Test
|
||||
public void shouldReturnObjectsForGivenIdsUsingMultiGetWithFields() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId)
|
||||
@ -198,7 +198,7 @@ public class ElasticsearchTemplateTests {
|
||||
LinkedList<SampleEntity> sampleEntities = elasticsearchTemplate.multiGet(query, SampleEntity.class, new MultiGetResultMapper() {
|
||||
@Override
|
||||
public <T> LinkedList<T> mapResults(MultiGetResponse responses, Class<T> clazz) {
|
||||
LinkedList<T> list = new LinkedList<T>();
|
||||
LinkedList<T> list = new LinkedList<>();
|
||||
for (MultiGetItemResponse response : responses.getResponses()) {
|
||||
SampleEntity entity = new SampleEntity();
|
||||
entity.setId(response.getResponse().getId());
|
||||
@ -236,7 +236,7 @@ public class ElasticsearchTemplateTests {
|
||||
@Test
|
||||
public void shouldDoBulkIndex() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId).message("some message")
|
||||
@ -280,7 +280,7 @@ public class ElasticsearchTemplateTests {
|
||||
UpdateQuery updateQuery = new UpdateQueryBuilder().withId(documentId)
|
||||
.withClass(SampleEntity.class).withIndexRequest(indexRequest).build();
|
||||
|
||||
List<UpdateQuery> queries = new ArrayList<UpdateQuery>();
|
||||
List<UpdateQuery> queries = new ArrayList<>();
|
||||
queries.add(updateQuery);
|
||||
|
||||
// when
|
||||
@ -375,7 +375,7 @@ public class ElasticsearchTemplateTests {
|
||||
@Test
|
||||
public void shouldSortResultsGivenSortCriteria() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId)
|
||||
@ -414,7 +414,7 @@ public class ElasticsearchTemplateTests {
|
||||
@Test
|
||||
public void shouldSortResultsGivenMultipleSortCriteria() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId)
|
||||
@ -488,7 +488,7 @@ public class ElasticsearchTemplateTests {
|
||||
elasticsearchTemplate.index(indexQuery);
|
||||
elasticsearchTemplate.refresh(SampleEntity.class);
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("factor", 2);
|
||||
// when
|
||||
SearchQuery searchQuery = new NativeSearchQueryBuilder()
|
||||
@ -638,11 +638,11 @@ public class ElasticsearchTemplateTests {
|
||||
Page<String> page = elasticsearchTemplate.queryForPage(searchQuery, String.class, new SearchResultMapper() {
|
||||
@Override
|
||||
public <T> AggregatedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable) {
|
||||
List<String> values = new ArrayList<String>();
|
||||
List<String> values = new ArrayList<>();
|
||||
for (SearchHit searchHit : response.getHits()) {
|
||||
values.add((String) searchHit.field("message").value());
|
||||
}
|
||||
return new AggregatedPageImpl<T>((List<T>) values);
|
||||
return new AggregatedPageImpl<>((List<T>) values);
|
||||
}
|
||||
});
|
||||
// then
|
||||
@ -731,7 +731,7 @@ public class ElasticsearchTemplateTests {
|
||||
criteriaQuery.setPageable(new PageRequest(0, 10));
|
||||
|
||||
String scrollId = elasticsearchTemplate.scan(criteriaQuery, 1000, false);
|
||||
List<SampleEntity> sampleEntities = new ArrayList<SampleEntity>();
|
||||
List<SampleEntity> sampleEntities = new ArrayList<>();
|
||||
boolean hasRecords = true;
|
||||
while (hasRecords) {
|
||||
Page<SampleEntity> page = elasticsearchTemplate.scroll(scrollId, 5000L, SampleEntity.class);
|
||||
@ -758,7 +758,7 @@ public class ElasticsearchTemplateTests {
|
||||
.withTypes(TYPE_NAME).withPageable(new PageRequest(0, 10)).build();
|
||||
|
||||
String scrollId = elasticsearchTemplate.scan(searchQuery, 1000, false);
|
||||
List<SampleEntity> sampleEntities = new ArrayList<SampleEntity>();
|
||||
List<SampleEntity> sampleEntities = new ArrayList<>();
|
||||
boolean hasRecords = true;
|
||||
while (hasRecords) {
|
||||
Page<SampleEntity> page = elasticsearchTemplate.scroll(scrollId, 5000L, SampleEntity.class);
|
||||
@ -791,13 +791,13 @@ public class ElasticsearchTemplateTests {
|
||||
criteriaQuery.setPageable(new PageRequest(0, 10));
|
||||
|
||||
String scrollId = elasticsearchTemplate.scan(criteriaQuery, 5000, false);
|
||||
List<SampleEntity> sampleEntities = new ArrayList<SampleEntity>();
|
||||
List<SampleEntity> sampleEntities = new ArrayList<>();
|
||||
boolean hasRecords = true;
|
||||
while (hasRecords) {
|
||||
Page<SampleEntity> page = elasticsearchTemplate.scroll(scrollId, 5000L, new SearchResultMapper() {
|
||||
@Override
|
||||
public <T> AggregatedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable) {
|
||||
List<SampleEntity> result = new ArrayList<SampleEntity>();
|
||||
List<SampleEntity> result = new ArrayList<>();
|
||||
for (SearchHit searchHit : response.getHits()) {
|
||||
String message = searchHit.getFields().get("message").getValue();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
@ -807,7 +807,7 @@ public class ElasticsearchTemplateTests {
|
||||
}
|
||||
|
||||
if (result.size() > 0) {
|
||||
return new AggregatedPageImpl<T>((List<T>) result);
|
||||
return new AggregatedPageImpl<>((List<T>) result);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -843,13 +843,13 @@ public class ElasticsearchTemplateTests {
|
||||
.build();
|
||||
|
||||
String scrollId = elasticsearchTemplate.scan(searchQuery, 10000, false);
|
||||
List<SampleEntity> sampleEntities = new ArrayList<SampleEntity>();
|
||||
List<SampleEntity> sampleEntities = new ArrayList<>();
|
||||
boolean hasRecords = true;
|
||||
while (hasRecords) {
|
||||
Page<SampleEntity> page = elasticsearchTemplate.scroll(scrollId, 10000L, new SearchResultMapper() {
|
||||
@Override
|
||||
public <T> AggregatedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable) {
|
||||
List<SampleEntity> result = new ArrayList<SampleEntity>();
|
||||
List<SampleEntity> result = new ArrayList<>();
|
||||
for (SearchHit searchHit : response.getHits()) {
|
||||
String message = searchHit.getFields().get("message").getValue();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
@ -859,7 +859,7 @@ public class ElasticsearchTemplateTests {
|
||||
}
|
||||
|
||||
if (result.size() > 0) {
|
||||
return new AggregatedPageImpl<T>((List<T>) result);
|
||||
return new AggregatedPageImpl<>((List<T>) result);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -892,13 +892,13 @@ public class ElasticsearchTemplateTests {
|
||||
criteriaQuery.setPageable(new PageRequest(0, 10));
|
||||
|
||||
String scrollId = elasticsearchTemplate.scan(criteriaQuery, 5000, false);
|
||||
List<SampleEntity> sampleEntities = new ArrayList<SampleEntity>();
|
||||
List<SampleEntity> sampleEntities = new ArrayList<>();
|
||||
boolean hasRecords = true;
|
||||
while (hasRecords) {
|
||||
Page<SampleEntity> page = elasticsearchTemplate.scroll(scrollId, 5000L, new SearchResultMapper() {
|
||||
@Override
|
||||
public <T> AggregatedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable) {
|
||||
List<SampleEntity> chunk = new ArrayList<SampleEntity>();
|
||||
List<SampleEntity> chunk = new ArrayList<>();
|
||||
for (SearchHit searchHit : response.getHits()) {
|
||||
if (response.getHits().getHits().length <= 0) {
|
||||
return null;
|
||||
@ -909,7 +909,7 @@ public class ElasticsearchTemplateTests {
|
||||
chunk.add(user);
|
||||
}
|
||||
if (chunk.size() > 0) {
|
||||
return new AggregatedPageImpl<T>((List<T>) chunk);
|
||||
return new AggregatedPageImpl<>((List<T>) chunk);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -937,13 +937,13 @@ public class ElasticsearchTemplateTests {
|
||||
.withTypes(TYPE_NAME).withPageable(new PageRequest(0, 10)).build();
|
||||
|
||||
String scrollId = elasticsearchTemplate.scan(searchQuery, 1000, false);
|
||||
List<SampleEntity> sampleEntities = new ArrayList<SampleEntity>();
|
||||
List<SampleEntity> sampleEntities = new ArrayList<>();
|
||||
boolean hasRecords = true;
|
||||
while (hasRecords) {
|
||||
Page<SampleEntity> page = elasticsearchTemplate.scroll(scrollId, 5000L, new SearchResultMapper() {
|
||||
@Override
|
||||
public <T> AggregatedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable) {
|
||||
List<SampleEntity> chunk = new ArrayList<SampleEntity>();
|
||||
List<SampleEntity> chunk = new ArrayList<>();
|
||||
for (SearchHit searchHit : response.getHits()) {
|
||||
if (response.getHits().getHits().length <= 0) {
|
||||
return null;
|
||||
@ -954,7 +954,7 @@ public class ElasticsearchTemplateTests {
|
||||
chunk.add(user);
|
||||
}
|
||||
if (chunk.size() > 0) {
|
||||
return new AggregatedPageImpl<T>((List<T>) chunk);
|
||||
return new AggregatedPageImpl<>((List<T>) chunk);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -985,7 +985,7 @@ public class ElasticsearchTemplateTests {
|
||||
criteriaQuery.setPageable(new PageRequest(0, 10));
|
||||
|
||||
String scrollId = elasticsearchTemplate.scan(criteriaQuery, 1000, false, SampleEntity.class);
|
||||
List<SampleEntity> sampleEntities = new ArrayList<SampleEntity>();
|
||||
List<SampleEntity> sampleEntities = new ArrayList<>();
|
||||
boolean hasRecords = true;
|
||||
while (hasRecords) {
|
||||
Page<SampleEntity> page = elasticsearchTemplate.scroll(scrollId, 5000L, SampleEntity.class);
|
||||
@ -1015,7 +1015,7 @@ public class ElasticsearchTemplateTests {
|
||||
.withPageable(new PageRequest(0, 10)).build();
|
||||
|
||||
String scrollId = elasticsearchTemplate.scan(searchQuery, 1000, false, SampleEntity.class);
|
||||
List<SampleEntity> sampleEntities = new ArrayList<SampleEntity>();
|
||||
List<SampleEntity> sampleEntities = new ArrayList<>();
|
||||
boolean hasRecords = true;
|
||||
while (hasRecords) {
|
||||
Page<SampleEntity> page = elasticsearchTemplate.scroll(scrollId, 5000L, SampleEntity.class);
|
||||
@ -1047,7 +1047,7 @@ public class ElasticsearchTemplateTests {
|
||||
criteriaQuery.setPageable(new PageRequest(0, 10));
|
||||
|
||||
CloseableIterator<SampleEntity> stream = elasticsearchTemplate.stream(criteriaQuery, SampleEntity.class);
|
||||
List<SampleEntity> sampleEntities = new ArrayList<SampleEntity>();
|
||||
List<SampleEntity> sampleEntities = new ArrayList<>();
|
||||
while (stream.hasNext()) {
|
||||
sampleEntities.add(stream.next());
|
||||
}
|
||||
@ -1055,7 +1055,7 @@ public class ElasticsearchTemplateTests {
|
||||
}
|
||||
|
||||
private static List<IndexQuery> createSampleEntitiesWithMessage(String message, int numberOfEntities) {
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
for (int i = 0; i < numberOfEntities; i++) {
|
||||
String documentId = UUID.randomUUID().toString();
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
@ -1074,7 +1074,7 @@ public class ElasticsearchTemplateTests {
|
||||
@Test
|
||||
public void shouldReturnListForGivenCriteria() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity1 = SampleEntity.builder().id(documentId)
|
||||
@ -1249,7 +1249,7 @@ public class ElasticsearchTemplateTests {
|
||||
Page<SampleEntity> sampleEntities = elasticsearchTemplate.queryForPage(searchQuery, SampleEntity.class, new SearchResultMapper() {
|
||||
@Override
|
||||
public <T> AggregatedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable) {
|
||||
List<SampleEntity> chunk = new ArrayList<SampleEntity>();
|
||||
List<SampleEntity> chunk = new ArrayList<>();
|
||||
for (SearchHit searchHit : response.getHits()) {
|
||||
if (response.getHits().getHits().length <= 0) {
|
||||
return null;
|
||||
@ -1261,7 +1261,7 @@ public class ElasticsearchTemplateTests {
|
||||
chunk.add(user);
|
||||
}
|
||||
if (chunk.size() > 0) {
|
||||
return new AggregatedPageImpl<T>((List<T>) chunk);
|
||||
return new AggregatedPageImpl<>((List<T>) chunk);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -1316,14 +1316,14 @@ public class ElasticsearchTemplateTests {
|
||||
Page<SampleEntity> page = elasticsearchTemplate.queryForPage(searchQuery, SampleEntity.class, new SearchResultMapper() {
|
||||
@Override
|
||||
public <T> AggregatedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable) {
|
||||
List<SampleEntity> values = new ArrayList<SampleEntity>();
|
||||
List<SampleEntity> values = new ArrayList<>();
|
||||
for (SearchHit searchHit : response.getHits()) {
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
sampleEntity.setId(searchHit.getId());
|
||||
sampleEntity.setMessage((String) searchHit.getSource().get("message"));
|
||||
values.add(sampleEntity);
|
||||
}
|
||||
return new AggregatedPageImpl<T>((List<T>) values);
|
||||
return new AggregatedPageImpl<>((List<T>) values);
|
||||
}
|
||||
});
|
||||
assertThat(page, is(notNullValue()));
|
||||
@ -1365,7 +1365,7 @@ public class ElasticsearchTemplateTests {
|
||||
@Test
|
||||
public void shouldReturnDocumentAboveMinimalScoreGivenQuery() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
|
||||
indexQueries.add(buildIndex(SampleEntity.builder().id("1").message("ab").build()));
|
||||
indexQueries.add(buildIndex(SampleEntity.builder().id("2").message("bc").build()));
|
||||
@ -1413,7 +1413,7 @@ public class ElasticsearchTemplateTests {
|
||||
@Test
|
||||
public void shouldDoBulkIndexWithoutId() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
sampleEntity1.setMessage("some message");
|
||||
@ -1446,14 +1446,14 @@ public class ElasticsearchTemplateTests {
|
||||
@Test
|
||||
public void shouldIndexMapWithIndexNameAndTypeAtRuntime() {
|
||||
//given
|
||||
Map<String, Object> person1 = new HashMap<String, Object>();
|
||||
Map<String, Object> person1 = new HashMap<>();
|
||||
person1.put("userId", "1");
|
||||
person1.put("email", "smhdiu@gmail.com");
|
||||
person1.put("title", "Mr");
|
||||
person1.put("firstName", "Mohsin");
|
||||
person1.put("lastName", "Husen");
|
||||
|
||||
Map<String, Object> person2 = new HashMap<String, Object>();
|
||||
Map<String, Object> person2 = new HashMap<>();
|
||||
person2.put("userId", "2");
|
||||
person2.put("email", "akonczak@gmail.com");
|
||||
person2.put("title", "Mr");
|
||||
@ -1472,7 +1472,7 @@ public class ElasticsearchTemplateTests {
|
||||
indexQuery2.setIndexName(INDEX_NAME);
|
||||
indexQuery2.setType(TYPE_NAME);
|
||||
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
indexQueries.add(indexQuery1);
|
||||
indexQueries.add(indexQuery2);
|
||||
|
||||
@ -1486,12 +1486,12 @@ public class ElasticsearchTemplateTests {
|
||||
Page<Map> sampleEntities = elasticsearchTemplate.queryForPage(searchQuery, Map.class, new SearchResultMapper() {
|
||||
@Override
|
||||
public <T> AggregatedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable) {
|
||||
List<Map> chunk = new ArrayList<Map>();
|
||||
List<Map> chunk = new ArrayList<>();
|
||||
for (SearchHit searchHit : response.getHits()) {
|
||||
if (response.getHits().getHits().length <= 0) {
|
||||
return null;
|
||||
}
|
||||
Map<String, Object> person = new HashMap<String, Object>();
|
||||
Map<String, Object> person = new HashMap<>();
|
||||
person.put("userId", searchHit.getSource().get("userId"));
|
||||
person.put("email", searchHit.getSource().get("email"));
|
||||
person.put("title", searchHit.getSource().get("title"));
|
||||
@ -1500,7 +1500,7 @@ public class ElasticsearchTemplateTests {
|
||||
chunk.add(person);
|
||||
}
|
||||
if (chunk.size() > 0) {
|
||||
return new AggregatedPageImpl<T>((List<T>) chunk);
|
||||
return new AggregatedPageImpl<>((List<T>) chunk);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -2000,14 +2000,14 @@ public class ElasticsearchTemplateTests {
|
||||
Page<ResultAggregator> page = elasticsearchTemplate.queryForPage(searchQuery, ResultAggregator.class, new SearchResultMapper() {
|
||||
@Override
|
||||
public <T> AggregatedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable) {
|
||||
List<ResultAggregator> values = new ArrayList<ResultAggregator>();
|
||||
List<ResultAggregator> values = new ArrayList<>();
|
||||
for (SearchHit searchHit : response.getHits()) {
|
||||
String id = String.valueOf(searchHit.getSource().get("id"));
|
||||
String firstName = StringUtils.isNotEmpty((String) searchHit.getSource().get("firstName")) ? (String) searchHit.getSource().get("firstName") : "";
|
||||
String lastName = StringUtils.isNotEmpty((String) searchHit.getSource().get("lastName")) ? (String) searchHit.getSource().get("lastName") : "";
|
||||
values.add(new ResultAggregator(id, firstName, lastName));
|
||||
}
|
||||
return new AggregatedPageImpl<T>((List<T>) values);
|
||||
return new AggregatedPageImpl<>((List<T>) values);
|
||||
}
|
||||
});
|
||||
|
||||
@ -2051,7 +2051,7 @@ public class ElasticsearchTemplateTests {
|
||||
}
|
||||
|
||||
private List<IndexQuery> getIndexQueries(List<SampleEntity> sampleEntities) {
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
for (SampleEntity sampleEntity : sampleEntities) {
|
||||
indexQueries.add(new IndexQueryBuilder().withId(sampleEntity.getId()).withObject(sampleEntity).build());
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors.
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -61,7 +61,7 @@ public class ElasticsearchTemplateCompletionTests {
|
||||
elasticsearchTemplate.refresh(CompletionEntity.class);
|
||||
elasticsearchTemplate.putMapping(CompletionEntity.class);
|
||||
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
indexQueries.add(new CompletionEntityBuilder("1").name("Rizwan Idrees").suggest(new String[]{"Rizwan Idrees"}).buildIndex());
|
||||
indexQueries.add(new CompletionEntityBuilder("2").name("Franck Marchand").suggest(new String[]{"Franck", "Marchand"}).buildIndex());
|
||||
indexQueries.add(new CompletionEntityBuilder("3").name("Mohsin Husen").suggest(new String[]{"Mohsin", "Husen"}, "Mohsin Husen").buildIndex());
|
||||
@ -81,7 +81,7 @@ public class ElasticsearchTemplateCompletionTests {
|
||||
nonDocumentEntity.setSomeField1("foo");
|
||||
nonDocumentEntity.setSomeField2("bar");
|
||||
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
indexQueries.add(new AnnotatedCompletionEntityBuilder("1").name("Franck Marchand").suggest(new String[]{"Franck", "Marchand"}).buildIndex());
|
||||
indexQueries.add(new AnnotatedCompletionEntityBuilder("2").name("Mohsin Husen").suggest(new String[]{"Mohsin", "Husen"}, "Mohsin Husen").buildIndex());
|
||||
indexQueries.add(new AnnotatedCompletionEntityBuilder("3").name("Rizwan Idrees").suggest(new String[]{"Rizwan", "Idrees"}, "Rizwan Idrees").buildIndex());
|
||||
@ -101,7 +101,7 @@ public class ElasticsearchTemplateCompletionTests {
|
||||
nonDocumentEntity.setSomeField1("Payload");
|
||||
nonDocumentEntity.setSomeField2("test");
|
||||
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
indexQueries.add(new AnnotatedCompletionEntityBuilder("1").name("Mewes Kochheim1").suggest(new String[]{"Mewes Kochheim1"}, null, Double.MAX_VALUE).buildIndex());
|
||||
indexQueries.add(new AnnotatedCompletionEntityBuilder("2").name("Mewes Kochheim2").suggest(new String[]{"Mewes Kochheim2"}, null, Long.MAX_VALUE).buildIndex());
|
||||
indexQueries.add(new AnnotatedCompletionEntityBuilder("3").name("Mewes Kochheim3").suggest(new String[]{"Mewes Kochheim3"}, null, "Payload test").buildIndex());
|
||||
@ -117,7 +117,7 @@ public class ElasticsearchTemplateCompletionTests {
|
||||
elasticsearchTemplate.refresh(AnnotatedCompletionEntity.class);
|
||||
elasticsearchTemplate.putMapping(AnnotatedCompletionEntity.class);
|
||||
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
indexQueries.add(new AnnotatedCompletionEntityBuilder("1").name("Mewes Kochheim1").suggest(new String[]{"Mewes Kochheim1"}).buildIndex());
|
||||
indexQueries.add(new AnnotatedCompletionEntityBuilder("2").name("Mewes Kochheim2").suggest(new String[]{"Mewes Kochheim2"}, null, null, 0).buildIndex());
|
||||
indexQueries.add(new AnnotatedCompletionEntityBuilder("3").name("Mewes Kochheim3").suggest(new String[]{"Mewes Kochheim3"}, null, null, 1).buildIndex());
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -49,10 +49,10 @@ public class ArticleEntity {
|
||||
@InnerField(suffix = "sort", type = String, store = true, indexAnalyzer = "keyword")
|
||||
}
|
||||
)
|
||||
private List<String> authors = new ArrayList<String>();
|
||||
private List<String> authors = new ArrayList<>();
|
||||
|
||||
@Field(type = Integer, store = true)
|
||||
private List<Integer> publishedYears = new ArrayList<Integer>();
|
||||
private List<Integer> publishedYears = new ArrayList<>();
|
||||
|
||||
private int score;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors.
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -55,7 +55,7 @@ public class ElasticsearchTemplateGeoTests {
|
||||
elasticsearchTemplate.refresh(AuthorMarkerEntity.class);
|
||||
elasticsearchTemplate.putMapping(AuthorMarkerEntity.class);
|
||||
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
indexQueries.add(new AuthorMarkerEntityBuilder("1").name("Franck Marchand").location(45.7806d, 3.0875d).buildIndex());
|
||||
indexQueries.add(new AuthorMarkerEntityBuilder("2").name("Mohsin Husen").location(51.5171d, 0.1062d).buildIndex());
|
||||
indexQueries.add(new AuthorMarkerEntityBuilder("3").name("Rizwan Idrees").location(51.5171d, 0.1062d).buildIndex());
|
||||
@ -69,7 +69,7 @@ public class ElasticsearchTemplateGeoTests {
|
||||
elasticsearchTemplate.refresh(LocationMarkerEntity.class);
|
||||
elasticsearchTemplate.putMapping(LocationMarkerEntity.class);
|
||||
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
double[] latLonArray = {0.100000, 51.000000};
|
||||
String lonLatString = "51.000000, 0.100000";
|
||||
String geohash = "u1044k2bd6u";
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors.
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -78,7 +78,7 @@ public class CriteriaQueryTests {
|
||||
@Test
|
||||
public void shouldPerformOrOperation() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
@ -117,7 +117,7 @@ public class CriteriaQueryTests {
|
||||
@Test
|
||||
public void shouldPerformAndOperationWithinCriteria() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
@ -144,7 +144,7 @@ public class CriteriaQueryTests {
|
||||
@Test
|
||||
public void shouldPerformOrOperationWithinCriteria() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
@ -170,7 +170,7 @@ public class CriteriaQueryTests {
|
||||
@Test
|
||||
public void shouldPerformIsOperation() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
@ -196,7 +196,7 @@ public class CriteriaQueryTests {
|
||||
@Test
|
||||
public void shouldPerformMultipleIsOperations() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
@ -234,7 +234,7 @@ public class CriteriaQueryTests {
|
||||
@Test
|
||||
public void shouldPerformEndsWithOperation() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
@ -273,7 +273,7 @@ public class CriteriaQueryTests {
|
||||
@Test
|
||||
public void shouldPerformStartsWithOperation() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
@ -312,7 +312,7 @@ public class CriteriaQueryTests {
|
||||
@Test
|
||||
public void shouldPerformContainsOperation() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
@ -350,7 +350,7 @@ public class CriteriaQueryTests {
|
||||
@Test
|
||||
public void shouldExecuteExpression() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
@ -388,7 +388,7 @@ public class CriteriaQueryTests {
|
||||
@Test
|
||||
public void shouldExecuteCriteriaChain() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
@ -427,7 +427,7 @@ public class CriteriaQueryTests {
|
||||
@Test
|
||||
public void shouldPerformIsNotOperation() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
@ -466,7 +466,7 @@ public class CriteriaQueryTests {
|
||||
@Test
|
||||
public void shouldPerformBetweenOperation() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
@ -505,7 +505,7 @@ public class CriteriaQueryTests {
|
||||
@Test
|
||||
public void shouldPerformBetweenOperationWithoutUpperBound() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
@ -545,7 +545,7 @@ public class CriteriaQueryTests {
|
||||
@Test
|
||||
public void shouldPerformBetweenOperationWithoutLowerBound() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
@ -585,7 +585,7 @@ public class CriteriaQueryTests {
|
||||
@Test
|
||||
public void shouldPerformLessThanEqualOperation() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
@ -625,7 +625,7 @@ public class CriteriaQueryTests {
|
||||
@Test
|
||||
public void shouldPerformGreaterThanEquals() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
@ -665,7 +665,7 @@ public class CriteriaQueryTests {
|
||||
@Test
|
||||
public void shouldPerformBoostOperation() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
// first document
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity1 = new SampleEntity();
|
||||
@ -704,7 +704,7 @@ public class CriteriaQueryTests {
|
||||
@Test
|
||||
public void shouldReturnDocumentAboveMinimalScoreGivenCriteria() {
|
||||
// given
|
||||
List<IndexQuery> indexQueries = new ArrayList<IndexQuery>();
|
||||
List<IndexQuery> indexQueries = new ArrayList<>();
|
||||
|
||||
indexQueries.add(buildIndex(SampleEntity.builder().id("1").message("ab").build()));
|
||||
indexQueries.add(buildIndex(SampleEntity.builder().id("2").message("bc").build()));
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -43,5 +43,5 @@ public class Book {
|
||||
@Field(type = FieldType.Object)
|
||||
private Author author;
|
||||
@Field(type = FieldType.Nested)
|
||||
private Map<Integer, Collection<String>> buckets = new HashMap<Integer, Collection<String>>();
|
||||
private Map<Integer, Collection<String>> buckets = new HashMap<>();
|
||||
}
|
||||
|
@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.entities;
|
||||
|
||||
import java.util.HashSet;
|
||||
@ -11,7 +26,6 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||
/**
|
||||
* Created by akonczak on 21/08/2016.
|
||||
*/
|
||||
|
||||
@Document(indexName = "groups", type = "group")
|
||||
public class Group {
|
||||
|
||||
@ -19,5 +33,5 @@ public class Group {
|
||||
String id;
|
||||
|
||||
@Field(type = FieldType.Nested, ignoreFields ={"groups"})
|
||||
private Set<User> users = new HashSet<User>();
|
||||
private Set<User> users = new HashSet<>();
|
||||
}
|
||||
|
@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright 2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.entities;
|
||||
|
||||
import java.util.HashSet;
|
||||
@ -11,12 +26,11 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
|
||||
/**
|
||||
* Created by akonczak on 21/08/2016.
|
||||
*/
|
||||
|
||||
@Document(indexName = "users", type = "user")
|
||||
public class User {
|
||||
@Id
|
||||
private String id;
|
||||
|
||||
@Field(type= FieldType.Nested,ignoreFields={"users"})
|
||||
private Set<Group> groups = new HashSet<Group>();
|
||||
private Set<Group> groups = new HashSet<>();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2016 the original author or authors.
|
||||
* Copyright 2013-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -1194,7 +1194,7 @@ public class CustomMethodRepositoryTests {
|
||||
}
|
||||
|
||||
private List<SampleEntity> createSampleEntities(String type, int numberOfEntities) {
|
||||
List<SampleEntity> entities = new ArrayList<SampleEntity>();
|
||||
List<SampleEntity> entities = new ArrayList<>();
|
||||
for (int i = 0; i < numberOfEntities; i++) {
|
||||
SampleEntity entity = new SampleEntity();
|
||||
entity.setId(randomNumeric(numberOfEntities));
|
||||
|
@ -534,7 +534,7 @@ public class SimpleElasticsearchRepositoryTests {
|
||||
}
|
||||
|
||||
private static List<SampleEntity> createSampleEntitiesWithMessage(String message, int numberOfEntities) {
|
||||
List<SampleEntity> sampleEntities = new ArrayList<SampleEntity>();
|
||||
List<SampleEntity> sampleEntities = new ArrayList<>();
|
||||
for (int i = 0; i < numberOfEntities; i++) {
|
||||
String documentId = randomNumeric(5);
|
||||
SampleEntity sampleEntity = new SampleEntity();
|
||||
|
@ -490,7 +490,7 @@ public class UUIDElasticsearchRepositoryTests {
|
||||
}
|
||||
|
||||
private static List<SampleEntityUUIDKeyed> createSampleEntitiesWithMessage(String message, int numberOfEntities) {
|
||||
List<SampleEntityUUIDKeyed> sampleEntities = new ArrayList<SampleEntityUUIDKeyed>();
|
||||
List<SampleEntityUUIDKeyed> sampleEntities = new ArrayList<>();
|
||||
for (int i = 0; i < numberOfEntities; i++) {
|
||||
UUID documentId = UUID.randomUUID();
|
||||
SampleEntityUUIDKeyed sampleEntityUUIDKeyed = new SampleEntityUUIDKeyed();
|
||||
|
Loading…
x
Reference in New Issue
Block a user