Skip to content

Commit

Permalink
HSEARCH-3193 Skip multi-indexes incompatibility checks with ES
Browse files Browse the repository at this point in the history
  • Loading branch information
fax4ever committed Nov 13, 2019
1 parent 6b08550 commit a20db3b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ public <T> ElasticsearchScopedIndexFieldComponent<T> getSchemaNodeComponent(Stri
public boolean hasSchemaObjectNodeComponent(String absoluteFieldPath) {
for ( ElasticsearchIndexModel indexModel : indexModels ) {
ElasticsearchIndexSchemaObjectNode objectNode = indexModel.getObjectNode( absoluteFieldPath );
// TODO HSEARCH-2389 check multi-indexes model incompatibility
// Even if we have an inconsistency with the Lucene backend,
// we decide to be very lenient here,
// allowing ALL the model incompatibilities Elasticsearch allows.
if ( objectNode != null ) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,9 @@ public boolean nonCanonicalRangeInAggregations() {
// Elasticsearch only supports [a, b), (-Infinity, b), [a, +Infinity), but not [a, b] for example.
return false;
}

@Override
public boolean lenientOnMultiIndexesCompatibilityChecks() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import static org.hibernate.search.util.impl.integrationtest.common.assertion.SearchHitsAssert.assertThat;
import static org.hibernate.search.util.impl.integrationtest.common.stub.mapper.StubMapperUtils.referenceProvider;
import static org.junit.Assume.assumeFalse;

import java.util.List;

Expand All @@ -21,6 +22,7 @@
import org.hibernate.search.engine.backend.types.Sortable;
import org.hibernate.search.engine.backend.work.execution.spi.IndexIndexingPlan;
import org.hibernate.search.engine.reporting.spi.EventContexts;
import org.hibernate.search.integrationtest.backend.tck.testsupport.util.TckConfiguration;
import org.hibernate.search.integrationtest.backend.tck.testsupport.util.rule.SearchSetupHelper;
import org.hibernate.search.util.common.SearchException;
import org.hibernate.search.util.impl.integrationtest.common.FailureReportUtils;
Expand Down Expand Up @@ -161,6 +163,7 @@ public void nested_multiIndexes_compatibleIndexMapping() {

@Test
public void nested_multiIndexes_incompatibleIndexMapping() {
assumeFullMultiIndexCompatibilityCheck();
StubMappingScope scope = indexManager.createScope( incompatibleIndexManager );

SubTest.expectException(
Expand Down Expand Up @@ -190,6 +193,7 @@ public void nested_multiIndexes_emptyIndexMapping() {

@Test
public void nested_multiIndexes_wrongStorageType() {
assumeFullMultiIndexCompatibilityCheck();
StubMappingScope scope = indexManager.createScope( invertedIndexManager );

SubTest.expectException(
Expand All @@ -206,6 +210,7 @@ public void nested_multiIndexes_wrongStorageType() {

@Test
public void nested_multiIndexes_differentFields() {
assumeFullMultiIndexCompatibilityCheck();
StubMappingScope scope = indexManager.createScope( differentFieldsIndexManager );

SubTest.expectException(
Expand All @@ -222,6 +227,7 @@ public void nested_multiIndexes_differentFields() {

@Test
public void nested_multiIndexes_incompatibleFields() {
assumeFullMultiIndexCompatibilityCheck();
StubMappingScope scope = indexManager.createScope( incompatibleFieldsIndexManager );

SubTest.expectException(
Expand All @@ -245,7 +251,7 @@ public void flattened() {
.fetchAllHits();

// DOCUMENT_2 won't be matched either, since it hasn't any not-null field
// DOCUMENT_4 will match, even if the matching field is not a direct field of the targeted path
// DOCUMENT_4 will match, even if the matching field is not a direct child of the targeted path
assertThat( docs ).hasDocRefHitsAnyOrder( INDEX_NAME, DOCUMENT_3, DOCUMENT_4 );
}

Expand All @@ -269,12 +275,13 @@ public void flattened_multiIndexes_compatibleIndexMapping() {
.fetchAllHits();

// DOCUMENT_2 won't be matched either, since it hasn't any not-null field
// DOCUMENT_4 will match, even if the matching field is not a direct field of the targeted path
// DOCUMENT_4 will match, even if the matching field is not a direct child of the targeted path
assertThat( docs ).hasDocRefHitsAnyOrder( INDEX_NAME, DOCUMENT_3, DOCUMENT_4 );
}

@Test
public void flattened_multiIndexes_incompatibleIndexMapping() {
assumeFullMultiIndexCompatibilityCheck();
StubMappingScope scope = incompatibleIndexManager.createScope( indexManager );

SubTest.expectException(
Expand All @@ -298,12 +305,13 @@ public void flattened_multiIndexes_emptyIndexMapping() {
.fetchAllHits();

// DOCUMENT_2 won't be matched either, since it hasn't any not-null field
// DOCUMENT_4 will match, even if the matching field is not a direct field of the targeted path
// DOCUMENT_4 will match, even if the matching field is not a direct child of the targeted path
assertThat( docs ).hasDocRefHitsAnyOrder( INDEX_NAME, DOCUMENT_3, DOCUMENT_4 );
}

@Test
public void flattened_multiIndexes_wrongStorageType() {
assumeFullMultiIndexCompatibilityCheck();
StubMappingScope scope = invertedIndexManager.createScope( indexManager );

SubTest.expectException(
Expand All @@ -320,6 +328,7 @@ public void flattened_multiIndexes_wrongStorageType() {

@Test
public void flattened_multiIndexes_differentFields() {
assumeFullMultiIndexCompatibilityCheck();
StubMappingScope scope = differentFieldsIndexManager.createScope( indexManager );

SubTest.expectException(
Expand All @@ -336,6 +345,7 @@ public void flattened_multiIndexes_differentFields() {

@Test
public void flattened_multiIndexes_incompatibleFields() {
assumeFullMultiIndexCompatibilityCheck();
StubMappingScope scope = incompatibleFieldsIndexManager.createScope( indexManager );

SubTest.expectException(
Expand Down Expand Up @@ -403,6 +413,13 @@ private void checkDocumentsCreation() {
assertThat( docs ).hasDocRefHitsAnyOrder( INDEX_NAME, DOCUMENT_0, DOCUMENT_1, DOCUMENT_2, DOCUMENT_3, DOCUMENT_4, DOCUMENT_5 );
}

private void assumeFullMultiIndexCompatibilityCheck() {
assumeFalse(
"We do not test some Multi-indexing compatibility checks if the backend allows these",
TckConfiguration.get().getBackendFeatures().lenientOnMultiIndexesCompatibilityChecks()
);
}

private static class IndexMapping {
final IndexFieldReference<String> string;
final IndexFieldReference<Integer> numeric;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@ public boolean flushWillFailIfAppliedToDeletedIndex() {
public boolean optimizeWillFailIfAppliedToDeletedIndex() {
return true;
}

public boolean lenientOnMultiIndexesCompatibilityChecks() {
// we decide to allow ALL the model incompatibilities Elasticsearch allows.
return false;
}
}

0 comments on commit a20db3b

Please sign in to comment.