It seems that it is impossible to have database-stored null or empty strings for domain properties annotated with @Facet.
I tried the configuration below:
a call to persist on a newly created IndexedObject() will yield the following exception:
The documentation states (18.104.22.168) that
null values should be avoided
, not that null values are not supported. I do understand that null/empty fields cannot be indexed, but I thought that was the goal of the @Field property indexNullAs, in order to have a marker in the index for null values. However it seems that the conversion from null in the index does not take this setting into account.
The only bypass that I have found is to define a default, non-null, non-empty value to any indexed property used in conjunction with @Facet within my domain object. That is extremely inconvenient since I would have to handle that specific "null" (for example) value throughout my application instead of only when filtering on facets.
Please let me know if I have missed something, or if there is a configuration bypass.
I just debugged the search code, and I think the fix seems simple.
The problem in my opinion is that the facet values are not using the information contained in DocumentFieldMetadata before storing the document in the index. Especially the indexAsNull property:
Thanks for the bug report and the analysis. I actually also looked at the code and came to the same conclusion. Are you interested in providing a pull request - http://hibernate.org/search/contribute/?
I think, however, that one cannot just call `fieldMetadata.indexNullAs`. One needs to check whether this is null as well and if so throw an exception in the lines of "trying to index null value w/o an explicit indexNullAs value". Otherwise, you will still get an exception in case `fieldMetadata.indexNullAs` returns null.
Agreed on your comments. I will try to submit a patch request soon. Thanks!