solr3.6到solr4.1升级,schema版本号区别等

应甲方公司要求,将现在正在使用的solr 3.6版本升到4.1,没有怎么了解4.1,但是驱使我们去升级solr版本的一个原因就是solr 3.6的cache机制会导致memory leak。

下面是我的替换过程,还是花了蛮久功夫的,可能是没有经历solr4.0的缘故么?

首先还是基于war包的solr4.1环境的搭建,与3.6没有区别,其实solr本身的东西更新起来基本没有任何问题,问题的关键就在于自己定制的一些功能。
1.分词
    在3.6版本中,solr.NGramTokenizerFactory是由org.apache.solr.analysis.BaseTokenizerFactory派生出来的,而在4.1中,取消了BaseTokenizerFactory这个类,而是直接从org.apache.lucene.analysis.util.TokenizerFactory这个类继承得到的。自定义的MyNGramFactory其实就是重写TokenizerFactory中的init和create方法。

2.similarity定制
    在3.6版本中,为了提高fieldNorm的精度,修改了lucene-core-xxx.jar(solr lucene-core.jar自定义)。而在4.1版本中,利用4.1版本的lucene,而lucene-core-4.1.0.jar中新集成了很多similarity,因而新增了一个package来存放这些不同的similarity类。
    因此将DefaultSimilarity中的idf方法修改为返回特定值(10),然后将DefaultSimilarity的父类TFIDFSimilarity中的NORM_TABLE按照上面链接中的方法修改即可。
3.schema中间有个version信息
    在刚刚搭好4.1,将3.6版本下建的索引copy到data目录下以后正要测试时,发现一个问题:
solr3.6到solr4.1升级,schema版本号区别等
即搜索“上海”找不到任何东西,debugQuery发现是parsedquery变成了“上 海 上海”,即对“上海”进行分词后得到了这样的一个合成的结果,只有1个term,这样显然是找不出任何结果的。而正确的parsedquery应该是:
solr3.6到solr4.1升级,schema版本号区别等

想了好多办法,一直对比schema和solrconfig文件,没有发现任何问题,直到:
solr3.6到solr4.1升级,schema版本号区别等
问题找出来了,原因是我新建出来的库中,schema文件中的version版本为"1.1",而在3.6版本下我的所有schema文件中的version都是"1.5",于是找到了

Schema version attribute in the root node

For the up-to-date documentation, see example example schema shipped with Solr

<schema name="example" version="1.5">
  <!-- attribute "name" is the name of this schema and is only used for display purposes.
       version="x.y" is Solr's version number for the schema syntax and 
       semantics.  It should not normally be changed by applications.

       1.0: multiValued attribute did not exist, all fields are multiValued 
            by nature
       1.1: multiValued attribute introduced, false by default 
       1.2: omitTermFreqAndPositions attribute introduced, true by default 
            except for text fields.
       1.3: removed optional field compress feature
       1.4: autoGeneratePhraseQueries attribute introduced to drive QueryParser
            behavior when a single string produces multiple tokens.  Defaults 
            to off for version >= 1.4
       1.5: omitNorms defaults to true for primitive field types 
            (int, float, boolean, string...)
     -->

注意1.4提到了autoGeneratePhraseQuerie这个属性,继续找,发现这个:

* SOLR-2015: Add a boolean attribute autoGeneratePhraseQueries to TextField. 
  (the default) causes the query parser to 
  generate phrase queries if multiple tokens are generated from a single 
  non-quoted analysis string.  For example WordDelimiterFilter splitting text:pdp-11 
  will cause the parser to generate text:"pdp 11" rather than (text:PDP OR text:11). 
  Note that tends to not work well for non whitespace 
  delimited languages. (yonik) 

这下就知道是什么情况了~~~。所以说schema.xml文件中的这个version也是有讲究的,不是摆设!将version改为1.5,done.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您好!对于将 Solr 8.8.2 升级的问题,以下是一些建议和步骤: 1. 准备工作: - 确保您已备份 Solr 的配置文件、数据和任何自定义插件。 - 阅读 Solr 官方升级文档,了解升级过程中的注意事项和可能的变化。 2. 下载 Solr 8.8.2: - 访问 Solr 官方网站 (https://lucene.apache.org/solr/) 下载 Solr 8.8.2 的二进制包。 3. 停止当前运行的 Solr 实例: - 停止 Solr 服务,确保所有的索引操作已完成。 4. 解压缩和配置新版本: - 将下载的二进制包解压缩到一个新的目录。 - 将之前备份的配置文件、数据和自定义插件复制到新的 Solr 目录。 - 检查并更新新版本的 solrconfig.xml 和 schema.xml 文件,确保与您的应用程序和需求相匹配。 5. 启动新版本的 Solr: - 运行启动脚本 (如 bin/solr start) 启动新版本的 Solr。 - 监控日志文件,确保 Solr 成功启动。 6. 运行升级向导: - 访问 Solr 的管理界面 (通常是 http://localhost:8983/),运行升级向导。 - 按照向导的指示进行升级过程,解决可能的冲突和问题。 7. 测试和验证: - 运行一些基本的查询和索引操作,确保 Solr 正常工作。 - 检查日志文件Solr 的状态页面,确保没有错误或警告。 请注意,这只是一个大致的升级指南,具体的步骤可能因您的环境和需求而有所不同。在进行升级之前,请确保充分了解 Solr 的新版本,并在测试环境中进行验证。如果您有任何特定的问题或疑虑,建议您向 Solr 官方社区寻求帮助或咨询专业人士。祝您升级顺利!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值