Skip to content

Commit dcef013

Browse files
committed
HSEARCH-3193 Test multi-indexes: object field - no field
1 parent 420d34e commit dcef013

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

integrationtest/backend/tck/src/main/java/org/hibernate/search/integrationtest/backend/tck/search/predicate/ObjectExistsSearchPredicateIT.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class ObjectExistsSearchPredicateIT {
3636
private static final String INDEX_NAME = "IndexName";
3737
private static final String COMPATIBLE_INDEX_NAME = "CompatibleIndexName";
3838
private static final String INCOMPATIBLE_INDEX_NAME = "IncompatibleIndexName";
39+
private static final String EMPTY_INDEX_NAME = "EmptyIndexName";
3940

4041
// this document is empty
4142
private static final String DOCUMENT_0 = "0";
@@ -65,6 +66,7 @@ public class ObjectExistsSearchPredicateIT {
6566
private StubMappingIndexManager indexManager;
6667
private StubMappingIndexManager compatibleIndexManager;
6768
private StubMappingIndexManager incompatibleIndexManager;
69+
private StubMappingIndexManager emptyIndexManager;
6870

6971
@Before
7072
public void setup() {
@@ -84,6 +86,11 @@ public void setup() {
8486
ctx -> new IncompatibleIndexMapping( ctx.getSchemaElement() ),
8587
indexManager -> this.incompatibleIndexManager = indexManager
8688
)
89+
.withIndex(
90+
EMPTY_INDEX_NAME,
91+
ctx -> { /* do not define any mapping here */ },
92+
indexManager -> this.emptyIndexManager = indexManager
93+
)
8794
.setup();
8895

8996
initData();
@@ -140,6 +147,18 @@ public void nested_multiIndexes_incompatibleIndexMapping() {
140147
) );
141148
}
142149

150+
@Test
151+
public void nested_multiIndexes_emptyIndexMapping() {
152+
StubMappingScope scope = indexManager.createScope( emptyIndexManager );
153+
154+
List<DocumentReference> docs = scope.query().asEntityReference()
155+
.predicate( p -> p.nested().objectField( "nested" ).nest( f -> f.exists().field( "nested" ) ) )
156+
.fetchAllHits();
157+
158+
// DOCUMENT_2 won't be matched either, since it hasn't any not-null field
159+
assertThat( docs ).hasDocRefHitsAnyOrder( INDEX_NAME, DOCUMENT_3 );
160+
}
161+
143162
@Test
144163
public void flattened() {
145164
StubMappingScope scope = indexManager.createScope();
@@ -191,6 +210,18 @@ public void flattened_multiIndexes_incompatibleIndexMapping() {
191210
) );
192211
}
193212

213+
@Test
214+
public void flattened_multiIndexes_emptyIndexMapping() {
215+
StubMappingScope scope = indexManager.createScope( emptyIndexManager );
216+
217+
List<DocumentReference> docs = scope.query().asEntityReference()
218+
.predicate( p -> p.exists().field( "flattened" ) )
219+
.fetchAllHits();
220+
221+
// DOCUMENT_2 won't be matched either, since it hasn't any not-null field
222+
assertThat( docs ).hasDocRefHitsAnyOrder( INDEX_NAME, DOCUMENT_3 );
223+
}
224+
194225
private void initData() {
195226
IndexIndexingPlan<? extends DocumentElement> plan = indexManager.createIndexingPlan();
196227
plan.add( referenceProvider( DOCUMENT_0 ), document -> { } );

0 commit comments

Comments
 (0)