> Not only is the query slow, but it seems to be slower the more results > it returns. > > > Any suggestions?
>> If you have a lot of terms in that range, you can see that there is obviously some cycles spinning to do the work needed. >> If the number of different date terms causes this effect, why not "round" the date to the nearest or next midnight while indexing. Thus, filtering for the last 15 days would require walking over 15-17 different date terms. If you don't do this, the number of different terms will be the same as the number of documents you indexed, explaining the slowing down when you have more results. Regards, Karsten -----Urspr�ngliche Nachricht----- Von: Erik Hatcher [mailto:[EMAIL PROTECTED] Gesendet: Samstag, 15. November 2003 17:31 An: Lucene Users List Betreff: Re: Slow response time with datefilter On Friday, November 14, 2003, at 07:16 PM, Dror Matalon wrote: > We're seeing slow response time when we apply datefilter. A search > that takes 7 msec with no datefilter takes 368 msec when I filter on > the last fifteen days, and 632 msec on the last 30 days. > > Initially we saved doing document.add(Field.Keyword("dtstamp", > dtstamp)); > > and then change to doing document.add(Field.Keyword("dtstamp", > DateField.dateToString(dtstamp))); > > where dtstamp is a java.util.Date Both of the above lines of code are equivalent. This is where having open-source is handy :) public static final Field Keyword(String name, Date value) { return new Field(name, DateField.dateToString(value), true, true, false); } > We search doing the following: > > days_ago_value = Long.parseLong(days); //could throw > NumberFormatException > days_ago_value = new java.util.Date().getTime() - (days_ago_value * > 86400000L); > hits = indexSearcher.search(query, DateFilter.After("dtstamp", > days_ago_value)); DateFilter itself is walking all the terms in the range you provide before executing the query. If you have a lot of terms in that range, you can see that there is obviously some cycles spinning to do the work needed. > Not only is the query slow, but it seems to be slower the more results > it returns. > > > Any suggestions? If this date range is pretty static, you could (in Lucene's CVS codebase) wrap the DateFilter with a CachingWrappingFilter. Or you could construct a long-lived instance of an equivalent QueryFilter and reuse it across multiple queries. You would likely see dramatic differences using either of these approaches. Erik --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
