Tinned_Tuna
Tinned_Tuna

Reputation: 237

How do you index a Set of UUIDs in Hibernate Search?

I have an entity in my application, which has a Set<UUID> on it, which I would like to index.

So far, I've tried putting @IndexEmbedded, @Field and @FieldBridge (which takes a UUID, not Set<UUID>) annotations on the Set<UUID> with no effect. The Hibernate Search docs all show indexing Set<X> where X is another entity which is has annotations on for indexing.

I'm testing to see if it turns up in the index by setting a breakpoint in Netbeans and manually inspecting the lucene index on disk using Luke, to rule out writing an incorrect query. Other fields are being indexed fine and showing up in the index using this method.

I am using Hibernate Search 3.4 at this time, since it's part of an older application and cannot be easily upgraded.

Can anyone shed some light on the situation? I am beginning to suspect this is not supported, and the fastest way will be to change from Set<UUID> to Set<Y>, where Y is an entity that simply wraps the UUID for indexing, or writing a specific FieldBridge to handle the Set<UUID>.

Upvotes: 1

Views: 506

Answers (1)

Hardy
Hardy

Reputation: 19129

You don't need @IndexedEmbedded, but you will need a custom bridge. Something like this should work:

@Field(bridge = @FieldBridge(impl = UUIDFieldBridge.class))
private Set<UUID> uuids;

It sounded like you already tried something like this. Did the bridge not even get called? Was there an exception?

Upvotes: 1

Related Questions