Hello. With Hibernate Search 3.4.2, I'm trying to filter out child objects by an expiration date, but I can seem to find the right way of doing this.
In pseudo code, here's what I want to accomplish: Code: class System { String code; Set<Component> components; }
class Component { String code; Date expirationDate; }
In the DB, System ABC has Components 123 (not expired) and 124 (expired). When searching for 123, ABC is getting filtered because 124 is expired. But I only want ABC to be filtered if searching for 124.
Here's the paraphrased code: Code: @Entity @Indexed class System { @Field String code;
@ManyToMany(fetch = FetchType.LAZY) @IndexedEmbedded Set<Component> components; }
@Entity class Component { @Field String code;
@Field(store = Store.YES) @DateBridge(resolution = Resolution.DAY) Date expirationDate;
@ManyToMany(mappedBy = "components") @ContainedIn Set<System> systems; }
The filter I'm using when searching Systems by code:
FieldCacheRangeFilter.newStringRange("components.expirationDate", null, "20131231", false, true);
Now when querying by 'code' with this filter, Systems are only returned that have 0 expired Components. I really want all Systems that have any unexpired Component with a code matching the search text.
Any help would be greatly appreciated. Thanks! -Bob
|