use of org.hibernate.search.engine.search.query.SearchQuery in project hibernate-search by hibernate.
the class IndexNullAsValueIT method indexNullAsValue_match.
@Test
public void indexNullAsValue_match() {
setUp();
StubMappingScope scope = index.createScope();
for (ByTypeFieldModel<?> fieldModel : index.binding().matchFieldModels) {
String absoluteFieldPath = fieldModel.relativeFieldName;
Object valueToMatch = fieldModel.indexNullAsValue.indexedValue;
SearchQuery<DocumentReference> query = scope.query().where(f -> f.match().field(absoluteFieldPath).matching(valueToMatch)).toQuery();
assertThatQuery(query).hasDocRefHitsAnyOrder(index.typeName(), DOCUMENT_WITH_INDEX_NULL_AS_VALUES, DOCUMENT_WITH_NULL_VALUES);
}
}
use of org.hibernate.search.engine.search.query.SearchQuery in project hibernate-search by hibernate.
the class SmokeIT method where_searchPredicate.
@Test
public void where_searchPredicate() {
StubMappingScope scope = index.createScope();
SearchPredicate predicate = scope.predicate().match().field("string").matching("text 1").toPredicate();
SearchQuery<DocumentReference> query = scope.query().where(predicate).toQuery();
assertThatQuery(query).hasDocRefHitsAnyOrder(index.typeName(), "1").hasTotalHitCount(1);
predicate = scope.predicate().range().field("integer").between(1, 2).toPredicate();
query = scope.query().where(predicate).toQuery();
assertThatQuery(query).hasDocRefHitsAnyOrder(index.typeName(), "1", "2").hasTotalHitCount(2);
predicate = scope.predicate().bool().should(f -> f.match().field("integer").matching(1)).should(f -> f.match().field("integer").matching(2)).toPredicate();
query = scope.query().where(predicate).toQuery();
assertThatQuery(query).hasDocRefHitsAnyOrder(index.typeName(), "1", "2").hasTotalHitCount(2);
}
use of org.hibernate.search.engine.search.query.SearchQuery in project hibernate-search by hibernate.
the class SmokeIT method where_boolean.
@Test
public void where_boolean() {
StubMappingScope scope = index.createScope();
SearchQuery<DocumentReference> query = scope.query().where(f -> f.bool().should(f.match().field("integer").matching(1)).should(f.match().field("integer").matching(2))).toQuery();
assertThatQuery(query).hasDocRefHitsAnyOrder(index.typeName(), "1", "2").hasTotalHitCount(2);
query = scope.query().where(f -> f.bool().must(f.match().field("string_analyzed").matching("text")).filter(f.match().field("integer").matching(1))).toQuery();
assertThatQuery(query).hasDocRefHitsAnyOrder(index.typeName(), "1").hasTotalHitCount(1);
query = scope.query().where(f -> f.bool().must(f.match().field("string_analyzed").matching("text")).mustNot(f.match().field("integer").matching(2))).toQuery();
assertThatQuery(query).hasDocRefHitsAnyOrder(index.typeName(), "1", "3").hasTotalHitCount(2);
}
use of org.hibernate.search.engine.search.query.SearchQuery in project hibernate-search by hibernate.
the class AnalysisBuiltinIT method assertMatchQuery.
private SearchResultAssert<DocumentReference> assertMatchQuery(SimpleFieldModel<String> fieldModel, String valueToMatch) {
StubMappingScope scope = index.createScope();
SearchQuery<DocumentReference> query = scope.query().where(f -> f.match().field(fieldModel.relativeFieldName).matching(valueToMatch)).toQuery();
return assertThatQuery(query);
}
use of org.hibernate.search.engine.search.query.SearchQuery in project hibernate-search by hibernate.
the class AnalysisBuiltinOverrideIT method assertMatchQuery.
private SearchResultAssert<DocumentReference> assertMatchQuery(SimpleFieldModel<String> fieldModel, String valueToMatch) {
StubMappingScope scope = index.createScope();
SearchQuery<DocumentReference> query = scope.query().where(f -> f.match().field(fieldModel.relativeFieldName).matching(valueToMatch)).toQuery();
return assertThatQuery(query);
}
Aggregations