打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
solr 配置tika 应用

solr 配置tika 应用

分类: 搜索引擎技术学习笔记433人阅读评论(0)收藏举报

首先是在solrconfig.xml,添加

  1. <!-- Solr Cell: http://wiki.apache.org/solr/ExtractingRequestHandler -->  
  2.   <requestHandler name="/update/extract" class="org.apache.solr.handler.extraction.ExtractingRequestHandler" startup="lazy">  
  3.     <lst name="defaults">  
  4.       <!-- All the main content goes into "text"... if you need to return  
  5.            the extracted text or do highlighting, use a stored field. -->  
  6.       <str name="fmap.content">text</str>  
  7.       <str name="lowernames">true</str>  
  8.       <str name="uprefix">ignored_</str>  
  9.         <!-- capture link hrefs but ignore div attributes -->  
  10.      </lst>  
  11.   </requestHandler>  

然后在%solr_home%/lib目录下添加扩展包:

从下载的solr项目中将

dist/apache-solr-cell-*.jar,

contrib/extraction/lib目录下的所有jar包,

加入到%solr_home%/lib.

运行solr:

使用solrj客户端编写相关的提交文档跟查询结果的代码 :如下



[c-sharp] view plaincopy?
  1. public void testTika() throws Exception {  
  2.     CommonsHttpSolrServer server = new CommonsHttpSolrServer(solrUrlString);  
  3.     ContentStreamUpdateRequest up = new ContentStreamUpdateRequest(  
  4.             "/update/extract");  
  5.     up.addFile(new File("tutorial.html"));  
  6.     up.setParam("literal.id""id");  
  7.     up.setAction(AbstractUpdateRequest.ACTION.COMMIT, truetrue);  
  8.     server.request(up);  
  9.     QueryResponse rsp = server.query(new SolrQuery("*:*"));  
  10.     System.out.println(rsp.getResults().getNumFound());  
  11.   
  12. }  

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Solr开发文档
solr5.3环境搭建
【solr基础教程之二】索引
Solr在tomcat下的配置
solr单机安装使用介绍 V7.4.0
基于Solr的HBase多条件查询测试
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服