日付による検索を意味する検索方法に時間制限を追加しようとしています。lucene は文字列しか処理できないことはわかっていますが、最初に日付を文字列に変換しています。しかし、まだ機能していません。コード ベースが複雑なため、なぜ機能していないのかよくわかりません。簡単なバージョンは次のとおりです。
@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
正しく実装されていない場所を見た人はいますか? ありがとうございました!