设为首页 收藏本站
查看: 1010|回复: 0

[经验分享] solr 4.3的一些错误解决方法

[复制链接]

尚未签到

发表于 2016-12-16 08:26:03 | 显示全部楼层 |阅读模式
在去年时候学习使用了solr4.0,现在solr版本最新已经到了4.3了,前两天因为工作需要在一台服务器上面新安装solr,但是生产环境是4.0,不过想到是内部测试用的,且主要功能就是写入,删除,搜索,与程序上面没有太多的深入开发,于是还是安装了最新的4.3版本
解压安装启动后,就可以了;这时需要添加collection,添加的collection配置需要与生产环境保持一致,于是复制默认的collection1 的配置信息作为新的collection
复制完成,新的collection events 也添加完成;但是加载时总是报错不能正确加载solrconfig.xml信息,也知道schema.xml等数据肯定是要修改的,schema.xml配置信息修改完成后还是有这样的问题,在往solr写入数据时又再次报错
undefined filed message,但是message字段确实已经配置好了;检查之后再次重启solr,查看刚才的events 直接显示 “There exists no core with name “events””
这时去查看日志,显示信息

1Caused by: org.apache.solr.common.SolrException: Error initializing QueryElevationComponent.



2at org.apache.solr.handler.component.QueryElevationComponent.inform(QueryElevationComponent.java:218)



3at org.apache.solr.core.SolrResourceLoader.inform(SolrResourceLoader.java:616)



4at org.apache.solr.core.SolrCore.<init>(SolrCore.java:816)



5... 34 more



6
Caused by: java.lang.NumberFormatException: For input string: "MA147LL/A"



7at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)



8... 36 more



9
ERROR - 2013-05-22 16:07:06.752; org.apache.solr.common.SolrException; org.apache.solr.common.SolrException: Error CREATEing SolrCore 'events': Unable to create core: events



10at org.apache.solr.handler.admin.CoreAdminHandler.handleCreateAction(CoreAdminHandler.java:524)



11...







 

1
ERROR - 2013-05-22 16:48:46.272; org.apache.solr.common.SolrException; org.apache.solr.common.SolrException: ERROR: [doc=100946] unknown field 'message'



2at org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:313)



3at org.apache.solr.update.AddUpdateCommand.getLuceneDocument(AddUpdateCommand.java:73)







正在排查中是,同事Y看到了,直接把solr 默认的collection1 改名为 events ,再次刷新直接挂了

There are no SolrCores running. Using the Solr Admin UI currently requires at least one SolrCore.
再次去查找这个问题,很快找到
http://stackoverflow.com/questions/13295208/i-unloaded-the-default-solr-collection-by-mistake-from-the-solr-admin-ui
编辑example/solr/solr.xml配置文件
可以看到已经变为

<core name="events" instanceDir="events" />
改为

<core name="collection1" instanceDir="collection1" />
保存,重启solr即可;
分析为什么出现这个问题,events collection的配置是错误的,solr初始化所有collection时跳过了events,而默认的collection1又改为了events则使用的是events目录下的配置信息了,
而这个配置信息又是错误的,所以solr admin 默认为没有 cores 的;修复过程中需要手动去修改配置文件,同事Y打呼用户体验太不友好了,不过我说Solr Admin用户体验很好啊,很早就不支持IE6了
现在又回到了上面的那个错误,org.apache.solr.common.SolrException: Error initializing QueryElevationComponent.
不能初始化,也不能添加events collection core,继续google,终于找到一篇提示的文章
https://coderwall.com/p/kwvxhq
Note that if you have enabled the QueryElevationComponent in solrconfig.xml it requires the schema to have a uniqueKey of typeStrField. It cannot be, for example, an int field.
Otherwise, you will get exception like:

java.lang.NumberFormatException: For input string: "MA147LL/A"
大意就是如果你开启了 QueryElevationComponent 功能,但是schema 的uniqueKey类型又不是 string,则报如下错误
java.lang.NumberFormatException: For input string: "MA147LL/A" 这个不就是我的日志里面的那个错误信息么, 于是编辑example/solr/events/conf/solrconfig.xml配置文件
搜索QueryElevationComponent关键字,可以看到如下,果然有这个信息

1<!-- Query Elevation Component



2 



3
http://wiki.apache.org/solr/QueryElevationComponent



4 



5a search component that enables you to configure the top



6
results for a given query regardless of the normal lucene



7scoring.



8-->



9
<searchComponent name="elevator" >



10<!-- pick a fieldType to analyze queries -->



11
<str name="queryFieldType">string</str>



12
<str name="config-file">elevate.xml</str>



13</searchComponent>







http://wiki.apache.org/solr/QueryElevationComponent 查看一下,类似于关键字搜索后,一些项的配置置顶显示 比如百度搜索某个关键字时,搜索框下面的推广,广告相关信息总是被置顶显示

要配置启用这项组件,需要配置elevate.xml,同样是位于example/solr/events/conf/目录下
Elevated query results are configured in an external .xml file determined by the config-file argument. An elevate.xml file may look like this:

<elevate>
<query text="AAA">
<doc id="A" />
<doc id="B" />
</query>
<query text="ipod">
<doc id="A" />
<!-- you can optionally exclude documents from a query result -->
<doc id="B" exclude="true" />
</query>
</elevate>
For the above configuration, the query “AAA” would first return documents A and B, then whatever normally appears for the same query. For the query “ipod”, it would first return A, and would make sure that B is not in the result set.
Note: The uniqueKey field must currently be of type string for the QueryElevationComponent to operate properly. 这就是答案了,uniquekey必须是string类型;目前我们项目中没有用到这项功能,所以可以选择注释不启用

1<!--



2
<searchComponent name="elevator" >



3<!-- pick a fieldType to analyze queries -->



4
<str name="queryFieldType">string</str>



5
<str name="config-file">elevate.xml</str>



6</searchComponent>



7-->







重启之后,没有初始化失败的错误了,再次往solr加入数据又有一个错误信息 undefined field text

1ERROR - 2013-05-22 17:59:51.107; org.apache.solr.common.SolrException; org.apache.solr.common.SolrException: undefined field text



2at org.apache.solr.schema.IndexSchema.getDynamicFieldType(IndexSchema.java:1211)



3at org.apache.solr.schema.IndexSchema$SolrQueryAnalyzer.getWrappedAnalyzer(IndexSchema.java:425)



4at org.apache.lucene.analysis.AnalyzerWrapper.initReader(AnalyzerWrapper.java:81)



5at org.apache.lucene.analysis.Analyzer.tokenStream(Analyzer.java:132)







google 得到结果,就是默认字段需要替换的问题,编辑 example/solr/events/conf/solrconfig.xml 检索到text内容

<lst name="defaults">
<str name="echoParams">explicit</str>
<int name="rows">10</int>
<str name="df">text</str>
</lst>
因为solrconfig.xml等配置文件时从collection1复制过来的,默认的default字段匹配是text,所以目前改为我们项目所用到的字段值message 保存文件,重启solr,写入数据没有问题了,search也正常的有数据内容返回了
版本的不同,配置文件内容也会做一些变动与修改;所以可能需要修改的配置不仅仅只是与项目search有关的内容,还有版本与版本之间,新版本默认启用的模块所需的配置有关;还有一点,多看日志,多用Google!





标签: solr作者:Alex阅读:3378回复:0日期:2013-05-23 15:40

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-314904-1-1.html 上篇帖子: solr配置主从同步配置及同步机制 下篇帖子: Solr中Cache的类型理解
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表