未定义的字段* solrj地理定位查询

时间:2016-07-10 15:00:11

标签: java solr lucene solrj

我正在尝试在我的solrj查询中使用位置地理函数。 我的solr查询是: -

q=*:*&sfield=latlng_coordinate&pt=70.00,80.000&sort=geodist() asc&fl=_dist_:geodist()&fl=name,id&fl=name,id

当我从浏览器点击此查询时,此查询正常工作但是当我尝试从我的java代码中搜索此查询时,它会抛出以下异常: -

SEVERE: org.apache.solr.common.SolrException: undefined field *
    at org.apache.solr.schema.IndexSchema.getDynamicFieldType(IndexSchema.java:1241)
    at org.apache.solr.schema.IndexSchema.getFieldType(IndexSchema.java:1193)
    at org.apache.solr.parser.SolrQueryParserBase.getWildcardQuery(SolrQueryParserBase.java:774)
    at org.apache.solr.parser.SolrQueryParserBase.handleBareTokenQuery(SolrQueryParserBase.java:521)
    at org.apache.solr.parser.QueryParser.Term(QueryParser.java:299)
    at org.apache.solr.parser.QueryParser.Clause(QueryParser.java:185)
    at org.apache.solr.parser.QueryParser.Query(QueryParser.java:107)
    at org.apache.solr.parser.QueryParser.TopLevelQuery(QueryParser.java:96)
    at org.apache.solr.parser.SolrQueryParserBase.parse(SolrQueryParserBase.java:152)
    at org.apache.solr.search.LuceneQParser.parse(LuceneQParser.java:50)
    at org.apache.solr.search.QParser.getQuery(QParser.java:141)
    at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:145)
    at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:196)
    at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
    at org.apache.solr.core.SolrCore.execute(SolrCore.java:1916)
    at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:768)
    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:415)
    at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:205)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)

Jul 10, 2016 8:22:30 PM org.apache.solr.core.SolrCore execute
INFO: [move2gathercollection] webapp=/solr path=/select params={q=*:*%26sfield%3Dlatlng_coordinate%26pt%3D70.00,80.000%26sort%3Dgeodist()+asc%26fl%3D_dist_:geodist()%26fl%3Dname,id&fl=name,id&wt=javabin&version=2} status=400 QTime=3 
org.apache.solr.client.solrj.impl.HttpSolrServer$RemoteSolrException: undefined field *
    at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:495)
    at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:199)
    at org.apache.solr.client.solrj.request.QueryRequest.process(QueryRequest.java:91)
    at org.apache.solr.client.solrj.SolrServer.query(SolrServer.java:301)
    at com.move2gather.search.SolrServerHelper.getSolrQueryResults(SolrServerHelper.java:172)
    at com.move2gather.search.data.SolrSearcher.getSuggesionsByGeoPoints(SolrSearcher.java:59)

尝试从过去4-5小时进行调试,但无法找到解决方案。

1 个答案:

答案 0 :(得分:0)

我认为请求网址存在问题。

看看move2gathercollection我看到查询没有完全编码。如果所有查询q=*:*都已编码,则应为q=*%3A*

因此,如果q参数被正确编码,则问题在于url的其余部分,可能在调用之前编码两次。

为了清楚起见,当我查看solr日志时,请求已经被解码,因此您可以读取所有参数。在您的日志中:

INFO: [move2gathercollection] webapp=/solr path=/select params={q=*:*%26sfield%3Dlatlng_coordinate%26pt%3D70.00,80.000%26sort%3Dgeodist()+asc%26fl%3D_dist_:geodist()%26fl%3Dname,id&fl=name,id&wt=javabin&version=2} status=400 QTime=3 

我看到只有请求的第一部分是可读的q=*:*,而其余的网址都是%26sfield%3Dlatlng_coordinate%26pt%3D70.00,80.000%26sort%3Dgeodist()+asc%26fl%3D_dist_:geodist()%26fl%3Dname编码的,这对我来说很奇怪。

我认为q:之后的整个字符串被读作以*开头的字段的名称。