Hello,
I'm trying to add hibernate search to a simple relational schema.
The main entity is Pharmacy having a collection of dates(care planning):
Code:
@Entity
@Indexed
public class Pharmacy implements Serializable {
@field
private int id;
@field
private String title;
@field
private String adress;
...
@Analyzer(definition = "customAnalyzer")
@IndexedEmbedded
@OneToMany(cascade = CascadeType.ALL)
private List<CareDate> careDates;
//getters, setters, equal...
}
the CareDate is a specific date where the pharmacy still opened at night (night care) or 24 or some other types of care
Code:
public class CareDate implements Serializable{
@id
private int id;
@field
private String beginDate;
@field
private String endDate;
@field
private String careType;
@JoinColumn(name = "id", referencedColumnName = "id", insertable = false, updatable = false)
@ManyToOne
private Pharmacy caringPharmacy;
...
}
the problem now is that when i want to check which pharmacy has a care date in a given date, let's say 2010-09-10 (yyyy-mm-dd); I tryed to combine two range queries :
Code:
+careDates.beginDate:[2010-09-10 TO *] +careDates.endDate:[* TO 2010-09-10]
the result is not correct when the collection contains two separate CareDate verifying separately the condition as the collection is combined when indexed; I mean this pharmacy may have two care dates([beginDate to endDate]):
[2010-09-01 to 2010-09-08] and [2010-09-12 to 2010-09-15]
here the given date is not included in any of those intervals but Lucene does not have the same point of view!!!
because the first interval validates the second part of the query and the second validates the first part.
any one has an idea? how can i deal with date range when i have such collections?
Thanks.