mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-22 12:02:10 +00:00
DATAES-82 - findAll(Iterable<ID> ids) does not work with Collections
terms query does not support iterable, converted Iterable to Collection
This commit is contained in:
parent
ad0409c7ae
commit
8c63f3ee22
@ -26,6 +26,7 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
|
import org.elasticsearch.common.collect.Lists;
|
||||||
import org.elasticsearch.index.query.QueryBuilder;
|
import org.elasticsearch.index.query.QueryBuilder;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -118,7 +119,9 @@ public abstract class AbstractElasticsearchRepository<T, ID extends Serializable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterable<T> findAll(Iterable<ID> ids) {
|
public Iterable<T> findAll(Iterable<ID> ids) {
|
||||||
SearchQuery query = new NativeSearchQueryBuilder().withQuery(inQuery(entityInformation.getIdAttribute(), ids))
|
Assert.notNull(ids, "ids can't be null.");
|
||||||
|
SearchQuery query = new NativeSearchQueryBuilder()
|
||||||
|
.withQuery(inQuery(entityInformation.getIdAttribute(), Lists.newArrayList(ids)))
|
||||||
.build();
|
.build();
|
||||||
return elasticsearchOperations.queryForPage(query, getEntityClass());
|
return elasticsearchOperations.queryForPage(query, getEntityClass());
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 the original author or authors.
|
* Copyright 2013-2014 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -24,8 +24,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.elasticsearch.common.collect.Lists;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -204,10 +204,11 @@ public class SimpleElasticsearchRepositoryTests {
|
|||||||
assertThat(page.getNumberOfElements(), is(greaterThanOrEqualTo(1)));
|
assertThat(page.getNumberOfElements(), is(greaterThanOrEqualTo(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
DATAES-82
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
@Ignore
|
|
||||||
public void shouldFindAllByIdQuery() {
|
public void shouldFindAllByIdQuery() {
|
||||||
// todo : find solution for findAll(Iterable<Ids> ids)
|
|
||||||
// given
|
// given
|
||||||
String documentId = randomNumeric(5);
|
String documentId = randomNumeric(5);
|
||||||
SampleEntity sampleEntity = new SampleEntity();
|
SampleEntity sampleEntity = new SampleEntity();
|
||||||
@ -228,6 +229,8 @@ public class SimpleElasticsearchRepositoryTests {
|
|||||||
|
|
||||||
// then
|
// then
|
||||||
assertNotNull("sample entities cant be null..", sampleEntities);
|
assertNotNull("sample entities cant be null..", sampleEntities);
|
||||||
|
List<SampleEntity> entities = Lists.newArrayList(sampleEntities);
|
||||||
|
assertThat(entities.size(), is(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user