我正在尝试将一个布尔计算字段添加到Solr请求中,如果文档的id字段位于指定的id列表中,则该字段为真。
我正试图这样做
fl=*,score,myfield:if(or(not(sub(id,1)),not(sub(id,2)),not(sub(id,3))),true,false)
但是
java.lang.UnsupportedOperationException
at org.apache.lucene.queries.function.FunctionValues.floatVal(FunctionValues.java:44)
at org.apache.solr.search.ValueSourceParser$17$1.func(ValueSourceParser.java:255)
at org.apache.lucene.queries.function.valuesource.DualFloatFunction$1.floatVal(DualFloatFunction.java:61)
at org.apache.lucene.queries.function.docvalues.FloatDocValues.intVal(FloatDocValues.java:51)
at org.apache.lucene.queries.function.FunctionValues.boolVal(FunctionValues.java:52)
at org.apache.solr.search.ValueSourceParser$68$1.func(ValueSourceParser.java:693)
at org.apache.lucene.queries.function.valuesource.SimpleBoolFunction$1.boolVal(SimpleBoolFunction.java:53)
at org.apache.solr.search.ValueSourceParser$70$1.func(ValueSourceParser.java:735)
at org.apache.lucene.queries.function.valuesource.MultiBoolFunction$1.boolVal(MultiBoolFunction.java:56)
at org.apache.lucene.queries.function.valuesource.IfFunction$1.objectVal(IfFunction.java:103)
at org.apache.solr.response.transform.ValueSourceAugmenter.transform(ValueSourceAugmenter.java:99)
at org.apache.solr.response.transform.DocTransformers.transform(DocTransformers.java:77)
at org.apache.solr.response.TextResponseWriter.writeDocuments(TextResponseWriter.java:273)
at org.apache.solr.response.TextResponseWriter.writeVal(TextResponseWriter.java:172)
at org.apache.solr.response.JSONWriter.writeNamedListAsMapWithDups(JSONResponseWriter.java:183)
at org.apache.solr.response.JSONWriter.writeNamedList(JSONResponseWriter.java:299)
at org.apache.solr.response.JSONWriter.writeResponse(JSONResponseWriter.java:95)
at org.apache.solr.response.JSONResponseWriter.write(JSONResponseWriter.java:60)
at org.apache.solr.servlet.SolrDispatchFilter.writeResponse(SolrDispatchFilter.java:647)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:375)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:158)
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(Thread.java:724)
我采取了一种完全错误的方法(除了我可以在Solr之外做到这一点),或者如果这样做是怎么做的,我应该改变什么才能使它工作?
答案 0 :(得分:1)
这应该可行(使用更多或()添加更多 id 值):
&fl=*,score,myfield:or(exists(query({!v='id:1'})),exists(query({!v='id:2'})))
失败的原因可能是id不是模式中的数字类型,因此您不能使用sub()。所以你仍然可以试试你的方式,但id应该是tint类型。