2012-05-16 271 views
2

我想做一個日期範圍查詢,但我總是有同樣的錯誤。問題是,當我添加+字符到日期範圍Solr日期範圍查詢

請求:

http://192.168.10.202:8080/solr/PageRequests/select/?q=request_datetime:[2011-09-01T00:21:57Z TO 2011-09-01T01:21:57Z+1HOUR]&version=2.2&start=0&rows=10&indent=on 

而且堆棧跟蹤:

at org.apache.solr.core.SolrCore.execute(SolrCore.java:1376) 
at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:365) 
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:260) 
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter( ApplicationFilterChain.java:243)  
at org.apache.catalina.core.Appl icationFilterChain.doFilter(Applicat ionFilterChain. java:210)  
at org.ap ache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve. java:225)  
at org.ap ache.catalina.core.StandardContextValve.invoke(StandardContextValve. java:169)  
at org.ap ache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase. java:472)  
at org.ap ache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) 
at org.ap ache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) 
at org.ap ache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) 
at org.ap ache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) 
at org.ap ache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) 
at org.ap ache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor. java:999)  
at org.ap ache.coyote.AbstractProtocol$AbstractConnectionHandler.process( AbstractP rotocol.java:565)  
at org.ap ache.tomcat.util. net.JIoEndpoint$SocketProcessor.run(JIoEndpoin t.java:307) 
at java.u til.concurrent.Th readPoolExecutor.runWorker(ThreadPoolExecutor. java:1110) 
at java.u til.concurrent.Th readPoolExecutor$Worker.run(ThreadPoolExecutor .java:603) 
at java.l ang.Thread.run(Th read.java:679)  
Caused by : org.apache.luce ne.queryParser .ParseException: Cannot parse  'request_datetime:[2011-09-01T00:21:57Z TO 2011-09-01T01:21:57Z 1HOUR] ':  Encounter ed " <RANGEIN_GOO P> "1HOUR "" a t line 1, column 63.  
Was expec ting:  
"]" ...  

at org.apache.lucene.queryParser.QueryParser.parse(QueryParser.java:211) 
at org.apache.solr.search.LuceneQParser.parse(LuceneQParserPlugin.java:79) 
at org.apache.solr.search.QParser.getQuery(QParser.java:143) 

回答

4

既然你以這種方式調用Solr的,你必須這樣做,以便+是URL編碼的,即用%2B代替。

+0

Works fine thanks :) –