use of org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueDistanceFromCenterValues.CENTER_POINT 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.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueDistanceFromCenterValues.CENTER_POINT 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.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueDistanceFromCenterValues.CENTER_POINT in project hibernate-search by hibernate.
the class DistanceSearchSortTypeCheckingAndConversionIT method multiIndex_withIncompatibleIndex.
@Test
public void multiIndex_withIncompatibleIndex() {
StubMappingScope scope = mainIndex.createScope(incompatibleIndex);
String fieldPath = getFieldPath();
assertThatThrownBy(() -> {
matchAllQuery(f -> f.distance(fieldPath, CENTER_POINT), scope);
}).isInstanceOf(SearchException.class).hasMessageContainingAll("Inconsistent configuration for field '" + fieldPath + "' in a search query across multiple indexes", "Inconsistent support for 'sort:distance'").satisfies(FailureReportUtils.hasContext(EventContexts.fromIndexNames(mainIndex.name(), incompatibleIndex.name())));
}
use of org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueDistanceFromCenterValues.CENTER_POINT in project hibernate-search by hibernate.
the class DistanceSearchSortBaseIT method factoryWithRoot.
@Test
@TestForIssue(jiraKey = "HSEARCH-4162")
public void factoryWithRoot() {
assumeTestParametersWork();
AbstractObjectBinding parentObjectBinding = index.binding().getParentObject(fieldStructure);
assumeTrue("This test is only relevant when the field is located on an object field", parentObjectBinding.absolutePath != null);
DataSet dataSet = dataSetForAsc;
assertThatQuery(index.query().where(f -> f.matchAll()).routing(dataSet.routingKey).sort(((Function<SearchSortFactory, DistanceSortOptionsStep<?, ?>>) f -> f.withRoot(parentObjectBinding.absolutePath).distance(parentObjectBinding.getRelativeFieldName(fieldStructure, fieldType), CENTER_POINT)).andThen(this::applySortMode).andThen(optionsStep -> {
if (fieldStructure.isInNested()) {
return optionsStep.filter(f -> f.match().field(AbstractObjectBinding.DISCRIMINATOR_FIELD_NAME).matching("included"));
} else {
return optionsStep;
}
}))).hasDocRefHitsExactOrder(index.typeName(), dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id, dataSet.emptyDoc1Id);
}
use of org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueDistanceFromCenterValues.CENTER_POINT in project hibernate-search by hibernate.
the class DistanceSortBaseIT method factoryWithRoot.
@Test
@TestForIssue(jiraKey = "HSEARCH-4162")
public void factoryWithRoot() {
assumeTestParametersWork();
AbstractObjectBinding parentObjectBinding = index.binding().getParentObject(fieldStructure);
assumeTrue("This test is only relevant when the field is located on an object field", parentObjectBinding.absolutePath != null);
DataSet dataSet = dataSetForAsc;
assertThatQuery(index.query().where(f -> f.matchAll()).routing(dataSet.routingKey).sort(((Function<SearchSortFactory, DistanceSortOptionsStep<?, ?>>) f -> f.withRoot(parentObjectBinding.absolutePath).distance(parentObjectBinding.getRelativeFieldName(fieldStructure, fieldType), CENTER_POINT)).andThen(this::applySortMode).andThen(optionsStep -> {
if (fieldStructure.isInNested()) {
return optionsStep.filter(f -> f.match().field(AbstractObjectBinding.DISCRIMINATOR_FIELD_NAME).matching("included"));
} else {
return optionsStep;
}
}))).hasDocRefHitsExactOrder(index.typeName(), dataSet.doc1Id, dataSet.doc2Id, dataSet.doc3Id, dataSet.emptyDoc1Id);
}
Aggregations