use of org.hibernate.search.engine.backend.common.DocumentReference in project hibernate-search by hibernate.
the class FieldSearchSortTypeCheckingAndConversionIT method multiIndex_withCompatibleIndex_usingField.
@Test
public void multiIndex_withCompatibleIndex_usingField() {
StubMappingScope scope = mainIndex.createScope(compatibleIndex);
SearchQuery<DocumentReference> query;
String fieldPath = getFieldPath();
query = matchAllQuery(f -> f.field(fieldPath).asc().missing().use(getSingleValueForMissingUse(BEFORE_DOCUMENT_1_ORDINAL)), scope);
/*
* Not testing the ordering of results here because some documents have the same value.
* It's not what we want to test anyway: we just want to check that fields are correctly
* detected as compatible and that no exception is thrown.
*/
assertThatQuery(query).hasDocRefHitsAnyOrder(b -> {
b.doc(mainIndex.typeName(), EMPTY);
b.doc(mainIndex.typeName(), DOCUMENT_1);
b.doc(mainIndex.typeName(), DOCUMENT_2);
b.doc(mainIndex.typeName(), DOCUMENT_3);
b.doc(compatibleIndex.typeName(), COMPATIBLE_INDEX_DOCUMENT_1);
});
}
use of org.hibernate.search.engine.backend.common.DocumentReference in project hibernate-search by hibernate.
the class DistanceSearchSortTypeCheckingAndConversionIT method multiIndex_withMissingFieldIndex.
@Test
@TestForIssue(jiraKey = "HSEARCH-4173")
public void multiIndex_withMissingFieldIndex() {
assumeTrue("This backend doesn't support distance sorts on a field that is missing from some of the target indexes.", TckConfiguration.get().getBackendFeatures().supportsDistanceSortWhenFieldMissingInSomeTargetIndexes());
StubMappingScope scope = mainIndex.createScope(missingFieldIndex);
SearchQuery<DocumentReference> query;
String fieldPath = getFieldPath();
query = matchNonEmptyQuery(f -> f.distance(fieldPath, CENTER_POINT), scope);
/*
* Not testing the ordering of results here because it's not what we are interested in:
* we just want to check that fields are correctly detected as compatible,
* that no exception is thrown and that the query is correctly executed on all indexes
* with no silent error (HSEARCH-4173).
*/
assertThatQuery(query).hasDocRefHitsAnyOrder(b -> {
b.doc(missingFieldIndex.typeName(), MISSING_FIELD_INDEX_DOCUMENT_1);
b.doc(mainIndex.typeName(), DOCUMENT_1);
b.doc(mainIndex.typeName(), DOCUMENT_2);
b.doc(mainIndex.typeName(), DOCUMENT_3);
});
}
use of org.hibernate.search.engine.backend.common.DocumentReference in project hibernate-search by hibernate.
the class DistanceSearchSortTypeCheckingAndConversionIT method multiIndex_withMissingFieldIndex_nested.
/**
* Test the behavior when even the <strong>parent</strong> field of the field to sort on is missing,
* and that parent field is <strong>nested</strong> in the main index.
*/
@Test
@TestForIssue(jiraKey = "HSEARCH-4173")
public void multiIndex_withMissingFieldIndex_nested() {
assumeTrue("This backend doesn't support distance sorts on a nested field that is missing from some of the target indexes.", TckConfiguration.get().getBackendFeatures().supportsDistanceSortWhenNestedFieldMissingInSomeTargetIndexes());
StubMappingScope scope = mainIndex.createScope(missingFieldIndex);
SearchQuery<DocumentReference> query;
String fieldPath = getFieldInNestedPath();
query = matchNonEmptyQuery(f -> f.distance(fieldPath, CENTER_POINT), scope);
/*
* Not testing the ordering of results here because it's not what we are interested in:
* we just want to check that fields are correctly detected as compatible,
* that no exception is thrown and that the query is correctly executed on all indexes
* with no silent error (HSEARCH-4173).
*/
assertThatQuery(query).hasDocRefHitsAnyOrder(b -> {
b.doc(missingFieldIndex.typeName(), MISSING_FIELD_INDEX_DOCUMENT_1);
b.doc(mainIndex.typeName(), DOCUMENT_1);
b.doc(mainIndex.typeName(), DOCUMENT_2);
b.doc(mainIndex.typeName(), DOCUMENT_3);
});
}
use of org.hibernate.search.engine.backend.common.DocumentReference in project hibernate-search by hibernate.
the class CompositeSearchSortIT method byComposite_separateSort.
@Test
public void byComposite_separateSort() {
StubMappingScope scope = index.createScope();
SearchQuery<DocumentReference> query;
query = simpleQuery(scope, scope.sort().composite().add(scope.sort().field(index.binding().identicalForFirstTwo.relativeFieldName).asc()).add(scope.sort().field(index.binding().identicalForLastTwo.relativeFieldName).asc()).toSort());
assertThatQuery(query).hasDocRefHitsExactOrder(index.typeName(), DOCUMENT_1, DOCUMENT_2, DOCUMENT_3);
query = simpleQuery(scope, scope.sort().composite().add(scope.sort().field(index.binding().identicalForFirstTwo.relativeFieldName).desc()).add(scope.sort().field(index.binding().identicalForLastTwo.relativeFieldName).desc()).toSort());
assertThatQuery(query).hasDocRefHitsExactOrder(index.typeName(), DOCUMENT_3, DOCUMENT_2, DOCUMENT_1);
query = simpleQuery(scope, scope.sort().composite().add(scope.sort().field(index.binding().identicalForFirstTwo.relativeFieldName).asc()).add(scope.sort().field(index.binding().identicalForLastTwo.relativeFieldName).desc()).toSort());
assertThatQuery(query).hasDocRefHitsExactOrder(index.typeName(), DOCUMENT_2, DOCUMENT_1, DOCUMENT_3);
query = simpleQuery(scope, scope.sort().composite().add(scope.sort().field(index.binding().identicalForFirstTwo.relativeFieldName).desc()).add(scope.sort().field(index.binding().identicalForLastTwo.relativeFieldName).asc()).toSort());
assertThatQuery(query).hasDocRefHitsExactOrder(index.typeName(), DOCUMENT_3, DOCUMENT_1, DOCUMENT_2);
}
use of org.hibernate.search.engine.backend.common.DocumentReference in project hibernate-search by hibernate.
the class FieldSearchSortTypeCheckingAndConversionIT method multiIndex_withMissingFieldIndex_nested.
/**
* Test the behavior when even the <strong>parent</strong> field of the field to sort on is missing,
* and that parent field is <strong>nested</strong> in the main index.
*/
@Test
@TestForIssue(jiraKey = "HSEARCH-4173")
public void multiIndex_withMissingFieldIndex_nested() {
assumeTrue("This backend doesn't support sorts on a field of type '" + fieldTypeDescriptor + "' that is missing from some of the target indexes.", TckConfiguration.get().getBackendFeatures().supportsFieldSortWhenFieldMissingInSomeTargetIndexes(fieldTypeDescriptor.getJavaType()));
assumeTrue("This backend doesn't support field sorts on a nested field that is missing from some of the target indexes.", TckConfiguration.get().getBackendFeatures().supportsFieldSortWhenNestedFieldMissingInSomeTargetIndexes());
StubMappingScope scope = mainIndex.createScope(missingFieldIndex);
SearchQuery<DocumentReference> query;
String fieldPath = getFieldInNestedPath();
query = matchNonEmptyQuery(f -> f.field(fieldPath).asc().missing().use(getSingleValueForMissingUse(BEFORE_DOCUMENT_1_ORDINAL)), scope);
/*
* Not testing the ordering of results here because it's not what we are interested in:
* we just want to check that fields are correctly detected as compatible,
* that no exception is thrown and that the query is correctly executed on all indexes
* with no silent error (HSEARCH-4173).
*/
assertThatQuery(query).hasDocRefHitsAnyOrder(b -> {
b.doc(missingFieldIndex.typeName(), MISSING_FIELD_INDEX_DOCUMENT_1);
b.doc(mainIndex.typeName(), DOCUMENT_1);
b.doc(mainIndex.typeName(), DOCUMENT_2);
b.doc(mainIndex.typeName(), DOCUMENT_3);
});
}
Aggregations