You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by matthias walter <ma...@smeet.de> on 2008/02/14 13:26:46 UTC
SolrQuery.add
Hi,
I'm having problems using SolrQuery.add(String, String).
My Sample code is:
SolrQuery anotherQuery = new SolrQuery();
anotherQuery.add("city", cmd.getCity());
I get the following error:
null java.lang.NullPointerException at
org.apache.solr.common.util.StrUtils.splitSmart(StrUtils.java:36) at
org.apache.solr.search.OldLuceneQParser.parse(LuceneQParserPlugin.java:104)
at org.apache.solr.search.QParser.getQuery(QParser.java:80) at
org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:66)
at
org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:143)
at
org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:117)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:902) at
org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:280)
at
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:237)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:541)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:619)
request:
http://localhost.local:8080/solr/select?city=Berlin&wt=xml&version=2.2
If I do it like that:
SolrQuery query = new SolrQuery();
query.setQuery("city:" + cmd.getCity() + " AND age:24");
Everything works fine.
It's not a real problem because the second version does the job, but the
code is quite ugly.
Thanks for your help,
Matthias
Re: SolrQuery.add
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Feb 14, 2008, at 7:26 AM, matthias walter wrote:
> I'm having problems using SolrQuery.add(String, String).
>
> My Sample code is:
> SolrQuery anotherQuery = new SolrQuery();
> anotherQuery.add("city", cmd.getCity());
This is incorrect (though admittedly confusing) use of the SolrQuery
API. What that does is the same as making this URL query: ?
city=<cmd.getCity()>
SolrQuery is-a SolrParams.
> If I do it like that:
>
> SolrQuery query = new SolrQuery();
> query.setQuery("city:" + cmd.getCity() + " AND age:24");
>
> Everything works fine.
>
> It's not a real problem because the second version does the job,
> but the code is quite ugly.
There ya go!
Erik