我需要过滤与cms中访问权限相对应的solr搜索结果(基于位掩码的drupal 7自定义访问控制机制).
有一个Solr QParserPlugin插件,用于基于整数字段https://issues.apache.org/jira/browse/SOLR-1913的按位运算来过滤搜索结果.
我在tomcat6(在Debian系统上)上使用Solr 3.6.1(/var/lib/tomcat6/solr/lib/bitwise_filter_plugin.jar中的插件),而drupal模块search_api_solr和solrconfig.xml中提供了schema.xml,则使用schema.xml模块发布队列(按照SOLR-1913问题扩展).
Solr查询…
http://solr:8080/solr/select?qf=t_title&fl=*,score&fq={!bitwise field=is_bitmask op=AND source=1234}*
…在错误日志中失败,并显示以下消息:
Sep 27, 2012 8:57:41 AM org.apache.solr.core.SolrCore execute
INFO: [] webapp=/solr path=/select params={qf=t_title&fl=*,score&fq={!bitwise+field%3Dis_bitmask+op%3DAND+source%3D1234}} status=500 QTime=15
Sep 27, 2012 8:57:41 AM org.apache.solr.common.SolrException log
SEVERE: java.lang.NullPointerException
at org.apache.lucene.search.FilteredQuery.hashCode(FilteredQuery.java:268)
at java.util.AbstractList.hashCode(AbstractList.java:542)
at org.apache.solr.search.QueryResultKey.<init>(QueryResultKey.java:49)
at org.apache.solr.search.SolrIndexSearcher.getDocListC(SolrIndexSearcher.java:1084)
at org.apache.solr.search.SolrIndexSearcher.search(SolrIndexSearcher.java:375)
at org.apache.solr.handler.component.QueryComponent.process(QueryComponent.java:394)
at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:186)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129)
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:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:636)
我在错误消息中只能看到的插件是由solr调用的.
任何帮助,将不胜感激,谢谢.
解决方法:
您可能不想尝试Solr,而是要尝试Solr的方法. Solr已经实现了布尔逻辑.
将您的位字段拆分为一组命名的布尔字段.如果您缺少灵感,它们甚至可以是bit_0,bit_1等.您可以使用动态字段来保存输入内容并允许以后进行扩展.
为每个文档将它们索引为bit_0:true,依此类推.
使用过滤器查询中的那些字段进行选择:bit_0:true和bit_24:true.
这可能比在每个字段上进行按位比较快得多.按位比较可能需要对每个查询进行全表扫描.好吧,全字段值扫描,因为Solr没有表.