Search in sources :

Example 1 with SearchSortFactory

use of org.hibernate.search.engine.search.sort.dsl.SearchSortFactory 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);
}
Also used : SearchException(org.hibernate.search.util.common.SearchException) GeoPoint(org.hibernate.search.engine.spatial.GeoPoint) GeoPointFieldTypeDescriptor(org.hibernate.search.integrationtest.backend.tck.testsupport.types.GeoPointFieldTypeDescriptor) BeforeClass(org.junit.BeforeClass) Assume.assumeFalse(org.junit.Assume.assumeFalse) RunWith(org.junit.runner.RunWith) SearchSetupHelper(org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper) SearchResultAssert.assertThatQuery(org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery) SearchSortFactory(org.hibernate.search.engine.search.sort.dsl.SearchSortFactory) Function(java.util.function.Function) AscendingUniqueDistanceFromCenterValues(org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueDistanceFromCenterValues) ArrayList(java.util.ArrayList) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) BulkIndexer(org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer) SimpleMappedIndex(org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex) SingleFieldIndexBinding(org.hibernate.search.integrationtest.backend.tck.testsupport.model.singlefield.SingleFieldIndexBinding) ClassRule(org.junit.ClassRule) DocumentReference(org.hibernate.search.engine.backend.common.DocumentReference) Parameterized(org.junit.runners.Parameterized) FieldTypeDescriptor(org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor) Sortable(org.hibernate.search.engine.backend.types.Sortable) CENTER_POINT(org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueDistanceFromCenterValues.CENTER_POINT) SortMode(org.hibernate.search.engine.search.common.SortMode) Set(java.util.Set) Test(org.junit.Test) IndexSchemaElement(org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement) StubMapperUtils.documentProvider(org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils.documentProvider) List(java.util.List) TestForIssue(org.hibernate.search.util.impl.test.annotation.TestForIssue) SearchQuery(org.hibernate.search.engine.search.query.SearchQuery) AbstractObjectBinding(org.hibernate.search.integrationtest.backend.tck.testsupport.model.singlefield.AbstractObjectBinding) Assume.assumeTrue(org.junit.Assume.assumeTrue) TestedFieldStructure(org.hibernate.search.integrationtest.backend.tck.testsupport.util.TestedFieldStructure) Collections(java.util.Collections) DistanceSortOptionsStep(org.hibernate.search.engine.search.sort.dsl.DistanceSortOptionsStep) TckConfiguration(org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration) Function(java.util.function.Function) AbstractObjectBinding(org.hibernate.search.integrationtest.backend.tck.testsupport.model.singlefield.AbstractObjectBinding) Test(org.junit.Test) TestForIssue(org.hibernate.search.util.impl.test.annotation.TestForIssue)

Example 2 with SearchSortFactory

use of org.hibernate.search.engine.search.sort.dsl.SearchSortFactory 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);
}
Also used : SearchException(org.hibernate.search.util.common.SearchException) Arrays(java.util.Arrays) GeoPoint(org.hibernate.search.engine.spatial.GeoPoint) GeoPointFieldTypeDescriptor(org.hibernate.search.integrationtest.backend.tck.testsupport.types.GeoPointFieldTypeDescriptor) BeforeClass(org.junit.BeforeClass) Assume.assumeFalse(org.junit.Assume.assumeFalse) RunWith(org.junit.runner.RunWith) SearchSort(org.hibernate.search.engine.search.sort.SearchSort) SearchSetupHelper(org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper) SearchResultAssert.assertThatQuery(org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery) SearchSortFactory(org.hibernate.search.engine.search.sort.dsl.SearchSortFactory) Function(java.util.function.Function) AscendingUniqueDistanceFromCenterValues(org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueDistanceFromCenterValues) ArrayList(java.util.ArrayList) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) BulkIndexer(org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer) SimpleMappedIndex(org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex) StubMappingScope(org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope) SingleFieldIndexBinding(org.hibernate.search.integrationtest.backend.tck.testsupport.model.singlefield.SingleFieldIndexBinding) ClassRule(org.junit.ClassRule) DocumentReference(org.hibernate.search.engine.backend.common.DocumentReference) Parameterized(org.junit.runners.Parameterized) FieldTypeDescriptor(org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor) Sortable(org.hibernate.search.engine.backend.types.Sortable) CENTER_POINT(org.hibernate.search.integrationtest.backend.tck.testsupport.types.values.AscendingUniqueDistanceFromCenterValues.CENTER_POINT) SortMode(org.hibernate.search.engine.search.common.SortMode) Set(java.util.Set) Test(org.junit.Test) IndexSchemaElement(org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement) StubMapperUtils.documentProvider(org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils.documentProvider) List(java.util.List) TestForIssue(org.hibernate.search.util.impl.test.annotation.TestForIssue) SearchQuery(org.hibernate.search.engine.search.query.SearchQuery) AbstractObjectBinding(org.hibernate.search.integrationtest.backend.tck.testsupport.model.singlefield.AbstractObjectBinding) Assume.assumeTrue(org.junit.Assume.assumeTrue) TestedFieldStructure(org.hibernate.search.integrationtest.backend.tck.testsupport.util.TestedFieldStructure) Collections(java.util.Collections) DistanceSortOptionsStep(org.hibernate.search.engine.search.sort.dsl.DistanceSortOptionsStep) TckConfiguration(org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration) Function(java.util.function.Function) AbstractObjectBinding(org.hibernate.search.integrationtest.backend.tck.testsupport.model.singlefield.AbstractObjectBinding) Test(org.junit.Test) TestForIssue(org.hibernate.search.util.impl.test.annotation.TestForIssue)

Example 3 with SearchSortFactory

use of org.hibernate.search.engine.search.sort.dsl.SearchSortFactory in project hibernate-search by hibernate.

the class FieldSortBaseIT 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<F> dataSet = dataSetForAsc;
    assertThatQuery(index.query().where(f -> f.matchAll().except(f.id().matchingAny(Arrays.asList(dataSet.emptyDoc1Id, dataSet.emptyDoc2Id, dataSet.emptyDoc3Id, dataSet.emptyDoc4Id)))).routing(dataSet.routingKey).sort(((Function<SearchSortFactory, FieldSortOptionsStep<?, ?>>) f -> f.withRoot(parentObjectBinding.absolutePath).field(parentObjectBinding.getRelativeFieldName(fieldStructure, fieldType))).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);
}
Also used : SearchException(org.hibernate.search.util.common.SearchException) Arrays(java.util.Arrays) BeforeClass(org.junit.BeforeClass) Assume.assumeFalse(org.junit.Assume.assumeFalse) FieldSortOptionsStep(org.hibernate.search.engine.search.sort.dsl.FieldSortOptionsStep) RunWith(org.junit.runner.RunWith) SearchSort(org.hibernate.search.engine.search.sort.SearchSort) SearchSetupHelper(org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper) SearchResultAssert.assertThatQuery(org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery) SearchSortFactory(org.hibernate.search.engine.search.sort.dsl.SearchSortFactory) Function(java.util.function.Function) ArrayList(java.util.ArrayList) PredicateFinalStep(org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) BulkIndexer(org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer) Locale(java.util.Locale) SimpleMappedIndex(org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex) StubMappingScope(org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope) SingleFieldIndexBinding(org.hibernate.search.integrationtest.backend.tck.testsupport.model.singlefield.SingleFieldIndexBinding) ClassRule(org.junit.ClassRule) DocumentReference(org.hibernate.search.engine.backend.common.DocumentReference) EnumSet(java.util.EnumSet) LinkedHashSet(java.util.LinkedHashSet) Parameterized(org.junit.runners.Parameterized) FieldTypeDescriptor(org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor) Sortable(org.hibernate.search.engine.backend.types.Sortable) SearchPredicateFactory(org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory) MonthDay(java.time.MonthDay) SortMode(org.hibernate.search.engine.search.common.SortMode) Set(java.util.Set) Test(org.junit.Test) IndexSchemaElement(org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement) StubMapperUtils.documentProvider(org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils.documentProvider) NormalizedStringFieldTypeDescriptor(org.hibernate.search.integrationtest.backend.tck.testsupport.types.NormalizedStringFieldTypeDescriptor) List(java.util.List) TestForIssue(org.hibernate.search.util.impl.test.annotation.TestForIssue) SearchHitsAssert.assertThatHits(org.hibernate.search.util.impl.integrationtest.common.assertion.SearchHitsAssert.assertThatHits) SearchQuery(org.hibernate.search.engine.search.query.SearchQuery) AbstractObjectBinding(org.hibernate.search.integrationtest.backend.tck.testsupport.model.singlefield.AbstractObjectBinding) Assume.assumeTrue(org.junit.Assume.assumeTrue) TestedFieldStructure(org.hibernate.search.integrationtest.backend.tck.testsupport.util.TestedFieldStructure) Temporal(java.time.temporal.Temporal) TckConfiguration(org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration) Function(java.util.function.Function) AbstractObjectBinding(org.hibernate.search.integrationtest.backend.tck.testsupport.model.singlefield.AbstractObjectBinding) Test(org.junit.Test) TestForIssue(org.hibernate.search.util.impl.test.annotation.TestForIssue)

Example 4 with SearchSortFactory

use of org.hibernate.search.engine.search.sort.dsl.SearchSortFactory in project hibernate-search by hibernate.

the class FieldSearchSortBaseIT 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<F> dataSet = dataSetForAsc;
    assertThatQuery(index.query().where(f -> f.matchAll().except(f.id().matchingAny(Arrays.asList(dataSet.emptyDoc1Id, dataSet.emptyDoc2Id, dataSet.emptyDoc3Id, dataSet.emptyDoc4Id)))).routing(dataSet.routingKey).sort(((Function<SearchSortFactory, FieldSortOptionsStep<?, ?>>) f -> f.withRoot(parentObjectBinding.absolutePath).field(parentObjectBinding.getRelativeFieldName(fieldStructure, fieldType))).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);
}
Also used : SearchException(org.hibernate.search.util.common.SearchException) Arrays(java.util.Arrays) BeforeClass(org.junit.BeforeClass) Assume.assumeFalse(org.junit.Assume.assumeFalse) FieldSortOptionsStep(org.hibernate.search.engine.search.sort.dsl.FieldSortOptionsStep) RunWith(org.junit.runner.RunWith) SearchSetupHelper(org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper) SearchResultAssert.assertThatQuery(org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery) SearchSortFactory(org.hibernate.search.engine.search.sort.dsl.SearchSortFactory) Function(java.util.function.Function) ArrayList(java.util.ArrayList) PredicateFinalStep(org.hibernate.search.engine.search.predicate.dsl.PredicateFinalStep) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) BulkIndexer(org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer) Locale(java.util.Locale) SimpleMappedIndex(org.hibernate.search.util.impl.integrationtest.mapper.stub.SimpleMappedIndex) StubMappingScope(org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMappingScope) SingleFieldIndexBinding(org.hibernate.search.integrationtest.backend.tck.testsupport.model.singlefield.SingleFieldIndexBinding) ClassRule(org.junit.ClassRule) DocumentReference(org.hibernate.search.engine.backend.common.DocumentReference) EnumSet(java.util.EnumSet) LinkedHashSet(java.util.LinkedHashSet) Parameterized(org.junit.runners.Parameterized) FieldTypeDescriptor(org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor) Sortable(org.hibernate.search.engine.backend.types.Sortable) SearchPredicateFactory(org.hibernate.search.engine.search.predicate.dsl.SearchPredicateFactory) MonthDay(java.time.MonthDay) SortMode(org.hibernate.search.engine.search.common.SortMode) Set(java.util.Set) Test(org.junit.Test) IndexSchemaElement(org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement) StubMapperUtils.documentProvider(org.hibernate.search.util.impl.integrationtest.mapper.stub.StubMapperUtils.documentProvider) NormalizedStringFieldTypeDescriptor(org.hibernate.search.integrationtest.backend.tck.testsupport.types.NormalizedStringFieldTypeDescriptor) List(java.util.List) TestForIssue(org.hibernate.search.util.impl.test.annotation.TestForIssue) SearchHitsAssert.assertThatHits(org.hibernate.search.util.impl.integrationtest.common.assertion.SearchHitsAssert.assertThatHits) SearchQuery(org.hibernate.search.engine.search.query.SearchQuery) AbstractObjectBinding(org.hibernate.search.integrationtest.backend.tck.testsupport.model.singlefield.AbstractObjectBinding) Assume.assumeTrue(org.junit.Assume.assumeTrue) TestedFieldStructure(org.hibernate.search.integrationtest.backend.tck.testsupport.util.TestedFieldStructure) Temporal(java.time.temporal.Temporal) TckConfiguration(org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration) Function(java.util.function.Function) AbstractObjectBinding(org.hibernate.search.integrationtest.backend.tck.testsupport.model.singlefield.AbstractObjectBinding) Test(org.junit.Test) TestForIssue(org.hibernate.search.util.impl.test.annotation.TestForIssue)

Aggregations

ArrayList (java.util.ArrayList)4 List (java.util.List)4 Set (java.util.Set)4 Function (java.util.function.Function)4 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)4 DocumentReference (org.hibernate.search.engine.backend.common.DocumentReference)4 IndexSchemaElement (org.hibernate.search.engine.backend.document.model.dsl.IndexSchemaElement)4 Sortable (org.hibernate.search.engine.backend.types.Sortable)4 SortMode (org.hibernate.search.engine.search.common.SortMode)4 SearchQuery (org.hibernate.search.engine.search.query.SearchQuery)4 SearchSortFactory (org.hibernate.search.engine.search.sort.dsl.SearchSortFactory)4 AbstractObjectBinding (org.hibernate.search.integrationtest.backend.tck.testsupport.model.singlefield.AbstractObjectBinding)4 SingleFieldIndexBinding (org.hibernate.search.integrationtest.backend.tck.testsupport.model.singlefield.SingleFieldIndexBinding)4 FieldTypeDescriptor (org.hibernate.search.integrationtest.backend.tck.testsupport.types.FieldTypeDescriptor)4 TckConfiguration (org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration)4 TestedFieldStructure (org.hibernate.search.integrationtest.backend.tck.testsupport.util.TestedFieldStructure)4 SearchSetupHelper (org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper)4 SearchException (org.hibernate.search.util.common.SearchException)4 SearchResultAssert.assertThatQuery (org.hibernate.search.util.impl.integrationtest.common.assertion.SearchResultAssert.assertThatQuery)4 BulkIndexer (org.hibernate.search.util.impl.integrationtest.mapper.stub.BulkIndexer)4