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

[经验分享] solr dataimport 的配置

[复制链接]

尚未签到

发表于 2015-7-16 13:36:12 | 显示全部楼层 |阅读模式
  1)在solrconfig.xml增加
  
   
   
  
      data-config.xml
   
   
  
  2)然后在solrconfig.xml同一个目录下,即是solr home目录下增加 data-config.xml 文件
  
  
   
   
        
        
            
            
         
            
               
            
            
               
            
            
               
            
            
            
               
               
               
            
            
        
        
   

  3)加入相关的jar包,apache-solr-dataimporthandler-1.4.0.jar,apache-solr-dataimporthandler-extras-1.4.0.jar,mysql-connector-java-5.1.10.jar
  
  启动tomcat,访问http://localhost:8080/solr/dataimport?command=full-import 将数据全部导入solr服务器进行索引
  访问http://localhost:8080/solr/dataimport?command=status可以查看运行状态
  当修改data-config.xml 文件配置时运行http://localhost:8080/solr/dataimport?command=reload-config可以进行重新加载配置文件
  如果想终止运行http://localhost:8080/solr/dataimport?command=abort
  
  要建立自己的全文检索,一般都需要从数据库导入数据,在原来配置的基础上,增加导入的功能

1、D:\apache-tomcat-7.0.27\solr\conf\solrconfig.xml中增加



Xml代码 http://zjnbshifox.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf?clipboard=%20%20%3CrequestHandler%20name%3D%22%2Fdataimport%22%20class%3D%22org.apache.solr.handler.dataimport.DataImportHandler%22%3E%0A%20%20%20%20%20%20%3Clst%20name%3D%22defaults%22%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%3Cstr%20name%3D%22config%22%3Edata-config.xml%3C%2Fstr%3E%0A%20%20%20%20%20%20%3C%2Flst%3E%0A%20%20%3C%2FrequestHandler%3E%0A DSC0000.png


  •    
  •           data-config.xml
  •    


2、增加D:\apache-tomcat-7.0.27\solr\conf\data-config.xml,内容为数据库的连接信息



Xml代码 http://zjnbshifox.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf?clipboard=%20%20%3C%3Fxml%20version%3D%221.0%22%20encoding%3D%22UTF-8%22%3F%3E%0A%3CdataConfig%3E%0A%3CdataSource%20type%3D%22JdbcDataSource%22%20driver%3D%22oracle.jdbc.driver.OracleDriver%22%0A%09url%3D%22jdbc%3Aoracle%3Athin%3A%4010.74.8.206%3A1521%3Aorcl%22%0A%09user%3D%22uname%22%0A%09password%3D%22pwd%22%2F%3E%0A%0A%3Cdocument%20name%3D%22zpxx%22%3E%20%20%20%20%20%20%20%20%20%0A%20%09%3Centity%20name%3D%22zpxx%22%20query%3D%22select%20*%20from%20vw_zp_fullindex%22%20transformer%3D%22ClobTransformer%22%3E%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%09%09%09%09%3Cfield%20column%3D%22GANG_WEI_BH%22%09%09name%3D%22GANG_WEI_BH%22%09%09%2F%3E%0A%09%09%09%09%3Cfield%20column%3D%22GANG_WEI_MC%22%09%09name%3D%22GANG_WEI_MC%22%09%09%2F%3E%0A%09%09%09%09%3Cfield%20column%3D%22GANG_WEI_MS%22%09%09name%3D%22GANG_WEI_MS%22%09%09%20clob%3D%22true%22%2F%3E%0A%09%09%09%09%3Cfield%20column%3D%22GONG_ZU_DD_ZW%22%09name%3D%22GONG_ZU_DD_ZW%22%09%2F%3E%0A%09%09%09%09%3Cfield%20column%3D%22QI_TA%22%09%09%09name%3D%22QI_TA%22%09%09%09%2F%3E%0A%09%09%09%09%3Cfield%20column%3D%22YUE_XIN%22%09%09%09name%3D%22YUE_XIN%22%09%09%09%2F%3E%0A%09%09%09%09%3Cfield%20column%3D%22ZHI_CHENG%22%09%09name%3D%22ZHI_CHENG%22%09%09%2F%3E%0A%09%09%09%09%3Cfield%20column%3D%22GANGWEILB%22%09%09name%3D%22GANGWEILB%22%09%09%2F%3E%0A%09%09%09%09%3Cfield%20column%3D%22COMPID%22%09%09%09name%3D%22COMPID%22%09%09%09%2F%3E%0A%09%09%09%09%3Cfield%20column%3D%22DAN_WEI_MC%22%09%09name%3D%22DAN_WEI_MC%22%09%09%2F%3E%0A%09%09%09%09%3Cfield%20column%3D%22DANWEIXZ%22%09%09name%3D%22DANWEIXZ%22%09%09%09%2F%3E%0A%09%09%09%09%3Cfield%20column%3D%22JING_YING_FW%22%09name%3D%22JING_YING_FW%22%09%09%2F%3E%0A%09%09%09%09%3Cfield%20column%3D%22DAN_WEI_JJ%22%09%09name%3D%22DAN_WEI_JJ%22%09%09%20clob%3D%22true%22%2F%3E%0A%09%09%09%09%3Cfield%20column%3D%22DAN_WEI_DZ%22%09%09name%3D%22DAN_WEI_DZ%22%09%09%2F%3E%0A%09%09%09%09%3Cfield%20column%3D%22HANGYELB%22%09%09name%3D%22HANGYELB%22%09%09%09%2F%3E%0A%20%20%20%20%3C%2Fentity%3E%0A%3C%2Fdocument%3E%0A%3C%2FdataConfig%3E%0A

  •   




  •    
  •                
  •                
  •                
  •                
  •                
  •                
  •                
  •                
  •                
  •                
  •                
  •                
  •                
  •                
  •                
  •    



因为有Clob字段,所以需要加上ClobTransformer
3、D:\apache-tomcat-7.0.27\solr\conf\schema.xml文件中增加



Xml代码 http://zjnbshifox.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf?clipboard=%20%20%3C!--%E8%87%AA%E5%AE%9A%E4%B9%89Field%E5%BC%80%E5%A7%8B%20--%3E%0A%09%09%09%09%3Cfield%20name%3D%22GANG_WEI_BH%22%09%09type%3D%22string%22%20indexed%3D%22true%22%20stored%3D%22true%22%20required%3D%22true%22%2F%3E%0A%09%09%09%09%3Cfield%20name%3D%22GANG_WEI_MC%22%09%09type%3D%22text%22%20indexed%3D%22true%22%20stored%3D%22true%22%20%2F%3E%0A%09%09%09%09%3Cfield%20name%3D%22GANG_WEI_MS%22%09%09type%3D%22text%22%20indexed%3D%22true%22%20stored%3D%22true%22%20%2F%3E%0A%09%09%09%09%3Cfield%20name%3D%22GONG_ZU_DD_ZW%22%09%09type%3D%22text%22%20indexed%3D%22true%22%20stored%3D%22true%22%20%2F%3E%0A%09%09%09%09%3Cfield%20name%3D%22QI_TA%22%09%09%09%09type%3D%22text%22%20indexed%3D%22true%22%20stored%3D%22true%22%20%2F%3E%0A%09%09%09%09%3Cfield%20name%3D%22YUE_XIN%22%09%09%09type%3D%22text%22%20indexed%3D%22true%22%20stored%3D%22true%22%20%2F%3E%0A%09%09%09%09%3Cfield%20name%3D%22ZHI_CHENG%22%09%09%09type%3D%22text%22%20indexed%3D%22true%22%20stored%3D%22true%22%20%2F%3E%0A%09%09%09%09%3Cfield%20name%3D%22GANGWEILB%22%09%09%09type%3D%22text%22%20indexed%3D%22true%22%20stored%3D%22true%22%20%2F%3E%0A%09%09%09%09%3Cfield%20name%3D%22COMPID%22%09%09%09type%3D%22string%22%20indexed%3D%22true%22%20stored%3D%22true%22%20%2F%3E%0A%09%09%09%09%3Cfield%20name%3D%22DAN_WEI_MC%22%09%09type%3D%22text%22%20indexed%3D%22true%22%20stored%3D%22true%22%20%2F%3E%0A%09%09%09%09%3Cfield%20name%3D%22DANWEIXZ%22%09%09%09type%3D%22text%22%20indexed%3D%22true%22%20stored%3D%22true%22%20%2F%3E%0A%09%09%09%09%3Cfield%20name%3D%22JING_YING_FW%22%09%09type%3D%22text%22%20indexed%3D%22true%22%20stored%3D%22true%22%20%2F%3E%0A%09%09%09%09%3Cfield%20name%3D%22DAN_WEI_JJ%22%09%09type%3D%22text%22%20indexed%3D%22true%22%20stored%3D%22true%22%20%2F%3E%0A%09%09%09%09%3Cfield%20name%3D%22DAN_WEI_DZ%22%09%09type%3D%22text%22%20indexed%3D%22true%22%20stored%3D%22true%22%20%2F%3E%0A%09%09%09%09%3Cfield%20name%3D%22HANGYELB%22%09%09%09type%3D%22text%22%20indexed%3D%22true%22%20stored%3D%22true%22%20%2F%3E%09%0A%09%3C!--%E8%87%AA%E5%AE%9A%E4%B9%89Field%E7%BB%93%E6%9D%9F%20--%3E%0A%0A%20%20%20%3CcopyField%20source%3D%22DAN_WEI_JJ%22%20dest%3D%22text%22%2F%3E%3C!--clob%E5%AD%97%E6%AE%B5%20--%3E%0A%20%20%20%3CcopyField%20source%3D%22GANG_WEI_MS%22%20dest%3D%22text%22%2F%3E%0A


  •             
  •             
  •             
  •             
  •             
  •             
  •             
  •             
  •             
  •             
  •             
  •             
  •             
  •             
  •             


  •   
  •   

把原有文件中id字段的required="true"去掉,否则导入的时候,会验证id字段,其实自己在做的时候,如果其他字段没有的话,可以删除
3、还要把oracle的jdbc驱动放到D:\apache-tomcat-7.0.27\webapps\solr\WEB-INF\lib
4、http://localhost:8080/solr/dataimport?command=full-import即可以进行导入数据
5、查询则通过http://localhost:8080/solr/admin/进行查询,输入查询字符串(Query String)"DAN_WEI_JJ:计算机"即可以查看全文检索结果

运维网声明 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-87343-1-1.html 上篇帖子: Solr主从集群配置简要说明 下篇帖子: [solr]
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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