Faceting on a field in SolrCloud with docValues=true and indexed=false fails
来源:互联网 发布:socket编程语言 编辑:程序博客网 时间:2024/05/01 07:19
最近在试着在SolrCloud中用docValues。不过在做某个docValues=true的数字域统计时,会报错。而在做String域的统计或者数字域的排序则没有问题。
我的int域型配置如下:
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
域配置如下:
<field name="type" type="int" indexed="false" stored="false" multiValued="false" docValues="true" useDocValuesAsStored="true"/>
之后读到文档中的这段话,便在域的配置中添加了required="true"
.
Default numeric field types. For faster range queries, consider the
tint/tfloat/tlong/tdouble types. These fields support doc values, but
they require the field to be single-valued and either be required or
have a default value.
但是结果还是有错误:
null:org.apache.solr.common.SolrException: Exception during facet.field: company_type at org.apache.solr.request.SimpleFacets$3.call(SimpleFacets.java:721) at org.apache.solr.request.SimpleFacets$3.call(SimpleFacets.java:706) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at org.apache.solr.request.SimpleFacets$2.execute(SimpleFacets.java:660) at org.apache.solr.request.SimpleFacets.getFacetFieldCounts(SimpleFacets.java:731) at org.apache.solr.handler.component.FacetComponent.getFacetCounts(FacetComponent.java:294) at org.apache.solr.handler.component.FacetComponent.process(FacetComponent.java:256) at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:272) at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:155) at org.apache.solr.core.SolrCore.execute(SolrCore.java:2102) at org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:654) at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:460) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:257) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:208) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:577) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.eclipse.jetty.server.Server.handle(Server.java:499) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:540) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) at java.lang.Thread.run(Thread.java:745)Caused by: java.lang.IllegalStateException: Cannot use facet.mincount=0 on field company_type which is not indexed at org.apache.solr.request.NumericFacets.getCounts(NumericFacets.java:257) at org.apache.solr.request.SimpleFacets.getTermCounts(SimpleFacets.java:454) at org.apache.solr.request.SimpleFacets.getTermCounts(SimpleFacets.java:382) at org.apache.solr.request.SimpleFacets$3.call(SimpleFacets.java:715) ... 33 more
Google了一下,找到这个issue,SOLR-5260。 上面有个patch,修改了/solr/core/src/java/org/apache/solr/request/NumericFacets.java的代码:
if (zeros && (limit < 0 || result.size() < limit)) { // need to merge with the term dict- if (!sf.indexed()) {- throw new IllegalStateException("Cannot use " + FacetParams.FACET_MINCOUNT + "=0 on field " + sf.getName() + " which is not indexed");+ if (!sf.indexed() && !sf.hasDocValues()) {+ throw new IllegalStateException("Cannot use " + FacetParams.FACET_MINCOUNT + "=0 on field " + sf.getName() + " which is neither indexed nor docValues"); } // Add zeros until there are limit results final Set<String> alreadySeen = new HashSet<>();
所以,先去http://www.apache.org/dyn/closer.lua/lucene/solr/5.5.4把solr-5.5.4-src.tgz下载并解压,导入Eclipse。点击File-Import-General-File System, 选择解压好的文件夹。
找到NumericFacets.java并修改代码。由于我这边把源代码导入后提示有错误,所以我把整个project导出jar包。
(这里注意Solr-5.5.4需要用java 1.7导出,我一开始使用了java 1.8,有个别Collection做facet的时候会报错:Error while processing facet fields: java.lang.UnsupportedClassVersionError,查了下这个错误是jdk版本号不对导致的)
然后用WinRAR打开jar包,复制NumericFacets相关的class,替换到原来Solr-5.5.4的solr-5.5.4\solr-5.5.4\server\solr-webapp\webapp\WEB-INF\lib\solr-core-5.5.4.jar中。
然后把修改过的solr-core-5.5.4放入服务器中对应的solr文件夹中/server/solr-webapp/webapp/WEB-INF/lib/solr-core-5.5.4。不用重新建索引,只需分别重启几个Solr节点,再测试docValues,可以使用facet。
- Faceting on a field in SolrCloud with docValues=true and indexed=false fails
- iselignored=false/true
- Rethink softCommit=true|false param on commits?
- MongoDB regular expression with indexed field
- True And False
- inverse=false or true
- inverse=true or false
- <%@ page isThreadSafe="true|false" %>
- <merge /> can be used only with a valid ViewGroup root and attachToRoot=true
- <merge /> can be used only with a valid ViewGroup root and attachToRoot=true
- boolean b=true?false:true==true?false:true;
- lucene搜索时出现异常unexpected docvalues type NONE for field 'modified' (expected=NUMERIC)
- [问与答]为什么 'a' in ('abc') 是True 而 'a' in ['abc'] 是False呢?
- True Positive,True Negative,False Positive and False Negative
- True Positive,True Negative,False Positive and False Negative
- {"acknowledged"=>true, "shards_acknowledged"=>false}
- Application.EnableEvents =false(true)的理解
- android android:duplicateParentState="true" "false"
- dubbo管控台不显示消费者
- ActivityThread的main()方法简读
- 专治AppStore搜不到
- JVM基础知识1
- 安卓framework层强制打开硬件加速
- Faceting on a field in SolrCloud with docValues=true and indexed=false fails
- TortoiseGit保存用户名密码
- live555 RTSP服务器建立及消息处理流程
- CentOS/Linux 开放80、8080端口或者开放某个端口
- Ridge Regression岭回归
- 用SQLServer 2014 还原数据库
- 公平席位分配的比例+惯例法和Q值法
- 深入理解操作系统虚拟内存
- Eclipse中出现Type 'xxxx' could not be resolved的处理方法