Hi Chris, Thanks for your suggestions. I did try the [NOW/DAY-7DAYS TO NOW/DAY], but it is not better. And I tried [NOW/DAY-7DAYS TO NOW/DAY+1DAY], I got some exception as below: org.apache.solr.core.SolrException: Query parsing error: Cannot parse 'account:1 AND recordeddate_dt:[NOW/DAYS-7DAYS TO NOW/DAY 1DAY]': Encountered "1DAY" at line 1, column 57. Was expecting: "]" ... at org.apache.solr.search.QueryParsing.parseQuery(QueryParsing.java:104) at org.apache.solr.request.StandardRequestHandler.handleRequestBody(Standar dRequestHandler.java:109) at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerB ase.java:77) at org.apache.solr.core.SolrCore.execute(SolrCore.java:658) at org.apache.solr.servlet.SolrServlet.doGet(SolrServlet.java:66) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHan dler.java:1093) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.j ava:185) at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHan dler.java:1084) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360) at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:2 16) at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726) at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405) at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandler Collection.java:206) at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.jav a:114) at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) at org.mortbay.jetty.Server.handle(Server.java:324) at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505) at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConne ction.java:828) at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:514) at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211) at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380) at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java: 395) at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.ja va:450) Caused by: org.apache.lucene.queryParser.ParseException: Cannot parse 'account:1 AND recordeddate_dt:[NOW/DAYS-7DAYS TO NOW/DAY 1DAY]': Encountered "1DAY" at line 1, column 57. Was expecting: "]" ... at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:152) at org.apache.solr.search.QueryParsing.parseQuery(QueryParsing.java:94) ... 26 more
And I will try to open the cache and see if I can get better query time. I will let you know. Thank you very much. Yongjun Rong -----Original Message----- From: Chris Hostetter [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 17, 2008 1:55 PM To: solr-user@lucene.apache.org Subject: Re: Search query optimization : Probably because the [NOW/DAYS-7DAYS+TO+NOW] part gets rewritten as lots : of OR clauses. I think that you'll see that if you add &debugQuery=true : to the URL. Make sure your recorded_date_dt is not too granular (e.g. : if you don't need minutes, round the values to hours. If you don't need : hours, round the values to days). for the record: it doesn't get rewritten to a lot of OR clauses, it's using ConstantScoreRangeQuery. granularity is definitely important however, bth when indexing and when querying. "NOW" is milliseconds, so every time you execute that query it's different and there is almost no caching possible. if you use [NOW/DAY-7DAYS TO NOW/DAY] or even [NOW/DAY-7DAYS TO NOW/HOUR] you'll get a lot better caching behavior. it looks like you are trying to find anything in the past week, so you may want [NOW/DAY-7DAYS TO NOW/DAY+1DAY] (to go to the end of the current day) once you have a less granular date restriction, it can frequently make sense to put this in a seperate fq clause, so it will get cached independently of your main query. But Otis's point about reducing granularity can also help when indexing ... the fewer "unique" dates that apepar in your index, the faster range queries will be ... if you've got 1000 documents that all of a recordeddate of June 11 2008, but at different times, and you're never going to care aboutthe times (just the date) then strip those times off when indexing so they all have the same fieled value of 2008-06-11T00:00:00Z BTW: the solr port you sent out a URL to ... all of it's caching is turned off (the filterCache and queryResultCache configs are commented out of your solrconfig.xml) ... you're going to wnat to turn on some caching or you'll never see really *great* request times. -Hoss