我在原始码头上运行solr 4.8.1并通过php脚本查询。当我在第一个光标标记上查询按价格和id排序的数据时,如“cursorMark = *”,它会正确返回。但是当用下一个光标标记再次查询时,我得到如下所示的错误。虽然当我使用某种创建日期或价格查询时,查询可以完美地运行。
完整查询如下所示:
http://localhost:8983/solr/collection1/select?q=age%3A".$age_q."+AND+gender%3A".$gender_q."+AND+category%3A".$category_q."+AND+type%3A".$type_q."+AND+price%3A".$price_q.$sort_q.$rows.$fl.$cursorMark
相关架构字段为:
<field name="title" type="text_general" indexed="true" stored="true" />
<field name="description" type="text_general" indexed="true" stored="true"/>
<field name="retailer" type="text_general" indexed="true" stored="true"/>
<field name="category" type="text_general" indexed="true" stored="true" />
<field name="main_image" type="text_general" indexed="true" stored="true"/>
<field name="last_modified" type="date" indexed="true" stored="true"/>
<field name="link" type="string" indexed="true" stored="true" />
<field name="age" type="text_general" indexed="true" stored="true"/>
<field name="gender" type="text_general" indexed="true" stored="true"/>
<field name="type" type="text_general" indexed="true" stored="true" />
<field name="creation_date" type="date" indexed="true" stored="true" />
<field name="price" type="float" indexed="true" stored="true"/>
<field name="subject" type="text_general" indexed="true" stored="true"/>
<field name="comments" type="text_general" indexed="true" stored="true"/>
<field name="author" type="text_general" indexed="true" stored="true"/>
<field name="keywords" type="text_general" indexed="true" stored="true"/>
<field name="resourcename" type="text_general" indexed="true" stored="true"/>
<field name="url" type="text_general" indexed="true" stored="true"/>
<field name="content_type" type="string" indexed="true" stored="true" />
<field name="links" type="string" indexed="true" stored="true" />
<field name="id" type="string" indexed="true" stored="true" required="true"
multiValued="false" />
`
php错误返回:
file_get_contents(http://localhost:8983/solr/collection1/select?q=age%3A*+AND+gender%3A*+AND+category%3A*+AND+type%3A*+AND+price%3A*&sort=creation_date+desc%2C+id+asc&start=0&rows=24&&fl=creation_date%2Cid%2Ctitle%2Cprice%2Cmain_image%2Clink&wt=json&indent=true&cursorMark=AoIIQpYAACIxNg==) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 500 Server Error
日志显示:
java.lang.ClassCastException: java.lang.Float cannot be cast to java.lang.Long
at org.apache.lucene.search.FieldComparator$LongComparator.setTopValue(FieldComparator.java:652)
at org.apache.lucene.search.TopFieldCollector$PagingFieldCollector.<init>(TopFieldCollector.java:877)
at org.apache.lucene.search.TopFieldCollector.create(TopFieldCollector.java:1183)
at org.apache.solr.search.SolrIndexSearcher.buildTopDocsCollector(SolrIndexSearcher.java:1495)
at org.apache.solr.search.SolrIndexSearcher.getDocListNC(SolrIndexSearcher.java:1596)
at org.apache.solr.search.SolrIndexSearcher.getDocListC(SolrIndexSearcher.java:1397)
at org.apache.solr.search.SolrIndexSearcher.search(SolrIndexSearcher.java:478)
at org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:461)
at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:218)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:135)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:1952)
at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:774)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:418)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:207)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:455)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:368)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:942)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1004)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:640)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)
at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Unknown Source)
答案 0 :(得分:0)
看起来你的演员阵容不正确:
java.lang.Float cannot be cast to java.lang.Long
我想我在文档中看到一些内容表明您无法在float
上进行范围查询,您可以使用sfloat
如果从AND+price%3A*
查询参数中删除q
会怎样?
逐字存储和索引文本值的数字字段类型(因此不支持范围查询,因为字典顺序不等于数字排序):
<fieldtype name="integer" class="solr.IntField" omitNorms="true"/> <fieldtype name="long" class="solr.LongField" omitNorms="true"/> <fieldtype name="float" class="solr.FloatField" omitNorms="true"/> <fieldtype name="double" class="solr.DoubleField" omitNorms="true"/>
数值字段类型,它将值操作为字符串值,该字符串值在其内部形式中不是人类可读的,但字典顺序与数字排序相同,以便范围查询正常工作。
<fieldtype name="sint" class="solr.SortableIntField" sortMissingLast="true" omitNorms="true"/> <fieldtype name="slong" class="solr.SortableLongField" sortMissingLast="true " omitNorms="true"/> <fieldtype name="sfloat" class="solr.SortableFloatField" sortMissingLast="tr ue" omitNorms="true"/> <fieldtype name="sdouble" class="solr.SortableDoubleField" sortMissingLast=" true" omitNorms="true"/>