[hibernate-dev] [HSEARCH-566] Indexing null values for an @ElementCollection

Sanne Grinovero sanne at hibernate.org
Sun Jul 31 15:44:13 EDT 2011


Hello,
initially we dealt with null values as by not indexing them; since we
have the "indexNullAs" option on @Field [1]
we allow to use a custom token in the index instead, so to make it
possible to search for entities having that field at null.

In case you would have a

@ElementCollection
@Field(indexNullAsl="nullToken")
String[] tags

having the value {"A","B",null}

I would expect this to be encoded in the index with three field
writes, all named "tags", and having values "A", "B", "nullToken".

But what if the array value is null by itself?

Personally I would expect it to *not* write anything, not encode the
"nullToken" which is reserved for an element being null: not having
the collection itself means in my opinion that there are no elements,
being similar as having an empty collection.

An alternative way could be to write the "nullToken" in both cases,
but I'm not liking this much as it would imply that the item will
match for a search similar to "all items having a null tag", while in
fact it had no tags at all.

I'd avoid adding more options as it would need a new annotation, or
adding options to other annotations which only apply in this case.
What do others think?

Sanne

1 - http://docs.jboss.org/hibernate/search/3.4/api/org/hibernate/search/annotations/Field.html#indexNullAs%28%29



More information about the hibernate-dev mailing list