indexNullAs for embedded entities


#1

According to the section “Indexing null embeddeds”, using indexNullAs should work, but when I inspect the index, using Luke, it doesn’t index null Sets.

Does it only work when it’s a single entity? Will it work in cases like this, from the MainEntity?:

@ContainedIn
@IndexedEmbedded(depth = 1, prefix = "mainEntity_", indexNullAs="nullToken")
@OneToMany(mappedBy = "mainEntity", fetch = FetchType.LAZY)
private Set<Child> children;

#2

We have a test for exactly that (org.hibernate.search.test.bridge.IterableBridgeNullEmbeddedTest#testSearchNullEmbedded), so yes, it should work with a null set. And it certainly does in our test.

As it is, when children is null, a field named mainEntity_ with value nullToken should be added to the index. Is this what you looked for with Luke?

If so, and if you can’t figure out what doesn’t work, you could try to set up a test case that reproduces your issue, and I can have a look. You can start from one of our test case templates.


#3

Doesn’t work. Oh well. Don’t have time to create a test case. There’s only instance where I need to do this. As a workaround, I created a transient indexable field that stores the “null” proxy value that I can check instead. Works. Not pretty but it’s just one field, so no biggie.