use of org.hibernate.search.engine.search.query.SearchQuery in project hibernate-search by hibernate.
the class IdentifierSearchProjectionBaseIT method validSuperClass.
@Test
public void validSuperClass() {
StubMappingScope scope = index.createScope();
SearchQuery<CharSequence> query = scope.query().select(f -> f.id(CharSequence.class)).where(f -> f.matchAll()).toQuery();
List<CharSequence> result = query.fetchHits(30);
assertThat(result).containsExactlyInAnyOrder(ids);
}
use of org.hibernate.search.engine.search.query.SearchQuery in project hibernate-search by hibernate.
the class IdentifierSearchProjectionBaseIT method simple.
@Test
public void simple() {
StubMappingScope scope = index.createScope();
SearchQuery<String> query = scope.query().select(f -> f.id(String.class)).where(f -> f.matchAll()).toQuery();
List<String> result = query.fetchHits(30);
assertThat(result).containsExactlyInAnyOrder(ids);
}
use of org.hibernate.search.engine.search.query.SearchQuery in project hibernate-search by hibernate.
the class IdentifierSearchProjectionBaseIT method multiIndex_withCompatibleIndex.
@Test
public void multiIndex_withCompatibleIndex() {
StubMappingScope scope = index.createScope(compatibleIndex);
SearchQuery<String> query = scope.query().select(f -> f.id(String.class)).where(f -> f.matchAll()).toQuery();
List<String> result = query.fetchHits(30);
String[] allIds = Stream.concat(Arrays.stream(ids), Arrays.stream(compatibleIndexIds)).toArray(String[]::new);
assertThat(result).containsExactlyInAnyOrder(allIds);
}
use of org.hibernate.search.engine.search.query.SearchQuery in project hibernate-search by hibernate.
the class CompositeSearchProjectionIT method compositeTriFunction_fromSearchProjectionObjects.
@Test
public void compositeTriFunction_fromSearchProjectionObjects() {
StubMappingScope scope = index.createScope();
SearchQuery<Book_Tri> query = scope.query().select(f -> f.composite(Book_Tri::new, f.field(index.binding().author.relativeFieldName, String.class).toProjection(), f.field(index.binding().title.relativeFieldName, String.class).toProjection(), f.field(index.binding().releaseDate.relativeFieldName, LocalDate.class).toProjection())).where(f -> f.matchAll()).toQuery();
assertThatQuery(query).hasHitsAnyOrder(new Book_Tri(index.binding().author.document1Value.indexedValue, index.binding().title.document1Value.indexedValue, index.binding().releaseDate.document1Value.indexedValue), new Book_Tri(index.binding().author.document2Value.indexedValue, index.binding().title.document2Value.indexedValue, index.binding().releaseDate.document2Value.indexedValue), new Book_Tri(index.binding().author.document3Value.indexedValue, index.binding().title.document3Value.indexedValue, index.binding().releaseDate.document3Value.indexedValue));
}
use of org.hibernate.search.engine.search.query.SearchQuery in project hibernate-search by hibernate.
the class CompositeSearchProjectionIT method compositeBiFunction_fromSearchProjectionObjects.
@Test
public void compositeBiFunction_fromSearchProjectionObjects() {
StubMappingScope scope = index.createScope();
SearchQuery<Book_Bi> query = scope.query().select(f -> f.composite(Book_Bi::new, f.field(index.binding().author.relativeFieldName, String.class).toProjection(), f.field(index.binding().title.relativeFieldName, String.class).toProjection())).where(f -> f.matchAll()).toQuery();
assertThatQuery(query).hasHitsAnyOrder(new Book_Bi(index.binding().author.document1Value.indexedValue, index.binding().title.document1Value.indexedValue), new Book_Bi(index.binding().author.document2Value.indexedValue, index.binding().title.document2Value.indexedValue), new Book_Bi(index.binding().author.document3Value.indexedValue, index.binding().title.document3Value.indexedValue));
}
Aggregations