I am trying to add time constraints to my search method which means searching by date. I know lucene can only handle strings, but I am converting the dates to string first. But it's still not working and due to the complexity of the code base I'm not quite sure why it's not working. Here's a simple version:
@Indexed
public class SomeDocument extends Document{
}
public abstract class Document extends BaseEntity{
}
@Indexed
public class BaseEntity {
@IndexedEmbedded
private Date lastUpdatedDate;
}
//snippet of search method
BooleanQuery bq = new BooleanQuery();
long oneDay = 1000L * 60 * 60 * 24;
long currentTime = System.currentTimeMillis();
Date dateOne = new Date(currentTime);
Date dateTwo = new Date(currentTime - (oneDay * 7)); // 1 week ago ago
TermRangeQuery dateQuery = new TermRangeQuery("lastUpdatedDate", dateTwo.toString(), dateOne.toString(), true, true);
bq.add(new BooleanClause(dateQuery, BooleanClause.Occur.MUST));
//more is added to boolean query, I create a full text query, and use the list() method
Does anyone see a place that is implemented incorrectly? Thank you!