You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Halácsy Péter <ha...@axelero.com> on 2002/04/24 23:24:44 UTC
DateFilter vs RangeQuery
Hello,
I have some documents indexed with a field date.created that is produced by DateField.dateToString. I want to filter the results for documents that were created in the last X day..
I don't understand what is the difference between:
Option I.
// perform the normal query and filter the result with a DateFilter
DateFilter df = new DateFilter.After("created", calendar.getTime());
Hits hits = mySearcher.search(myQuery, df);
Option II.
// add a clause to the original query
Term t = new Term("created", DateField.dateToField(calendar.getTime()));
BooleanQuery q = new BooleanQuery();
q.add(myQuery, true, false);
q.add(new RangeQuery(t, null, true));
Hits hits = mySearcher.search(q);
Could someone help to decide which option is better?
thanks,
peter
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>