Skip to content

Commit

Permalink
HSEARCH-3193 Support exists targeting objects with ES
Browse files Browse the repository at this point in the history
  • Loading branch information
fax4ever committed Nov 13, 2019
1 parent c2f7340 commit 7ee2589
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ public <T> ElasticsearchScopedIndexFieldComponent<T> getSchemaNodeComponent(Stri
return scopedIndexFieldComponent;
}

public boolean hasSchemaObjectNodeComponent(String absoluteFieldPath) {
for ( ElasticsearchIndexModel indexModel : indexModels ) {
ElasticsearchIndexSchemaObjectNode objectNode = indexModel.getObjectNode( absoluteFieldPath );
// TODO HSEARCH-2389 check multi-indexes model incompatibility
if ( objectNode != null ) {
return true;
}
}

return false;
}

public void checkNestedField(String absoluteFieldPath) {
boolean found = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ public SimpleQueryStringPredicateBuilder<ElasticsearchSearchPredicateBuilder> si

@Override
public ExistsPredicateBuilder<ElasticsearchSearchPredicateBuilder> exists(String absoluteFieldPath) {
// Make sure to fail for fields with different type or for unknown fields
// We may be able to relax this constraint, but that would require more extensive testing
scopeModel.getSchemaNodeComponent( absoluteFieldPath, PREDICATE_BUILDER_FACTORY_RETRIEVAL_STRATEGY );
if ( !scopeModel.hasSchemaObjectNodeComponent( absoluteFieldPath ) ) {
// Make sure to fail for fields with different type or for unknown fields
// We may be able to relax this constraint, but that would require more extensive testing
scopeModel.getSchemaNodeComponent( absoluteFieldPath, PREDICATE_BUILDER_FACTORY_RETRIEVAL_STRATEGY );
}
return new ElasticsearchExistsPredicateBuilder( absoluteFieldPath );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void numeric() {
assertThat( docs ).hasDocRefHitsAnyOrder( INDEX_NAME, DOCUMENT_1, DOCUMENT_2, DOCUMENT_3 );
}

// TODO HSEARCH-2389 allows @Test
@Test
public void nested() {
StubMappingScope scope = indexManager.createScope();

Expand All @@ -111,7 +111,7 @@ public void nested() {
assertThat( docs ).hasDocRefHitsAnyOrder( INDEX_NAME, DOCUMENT_3 );
}

// TODO HSEARCH-2389 allows @Test
@Test
public void flattened() {
StubMappingScope scope = indexManager.createScope();

Expand Down

0 comments on commit 7ee2589

Please sign in to comment.