Apache SOLR and Carrot2集成
1.环境
下载软件
名称 |
地址 |
solr-integration-strategies-gh-pages.zip |
|
solr-4.7.1 |
|
apache-tomcat-6.0.39 |
|
carrot2-webapp-3.9.2.war |
2.启动Solr
使用Jetty启动solr
F:\solr\solr-4.7.1\example>java -Dsolr.solr.home=../../carrot2-3.8.0-4.7.1/solr-home -jar start.jar |
访问http://localhost:8983/solr/#/
3.导入数据
使用solr-docs中post.jar向solr中导入数据
F:\solr\solr-integration-strategies-gh-pages\solr-docs>java -jar post.jar 20newsgroups |
4.聚类集成到Solr中
carrot2提供的solrconfig.xml中的对搜索结果进行了配置
<lib dir="../../../solr-4.7.1/contrib/clustering/lib/" regex=".*\.jar" /> <lib dir="../../../solr-4.7.1/dist/" regex=".*solr-clustering-.*\.jar" /> |
<!-- Declare a clustering search component, configure a single engine (Lingo algorithm) --> <searchComponent name="clustering" enable="true" class="solr.clustering.ClusteringComponent" > <lst name="engine"> <str name="name">default</str> <str name="carrot.algorithm">org.carrot2.clustering.lingo.LingoClusteringAlgorithm</str> <str name="LingoClusteringAlgorithm.desiredClusterCountBase">20</str> <str name="carrot.lexicalResourcesDir">clustering/carrot2</str> <str name="MultilingualClustering.defaultLanguage">ENGLISH</str> </lst> </searchComponent> |
配置
config1_1(search handler):
<requestHandler name="/config1_1" class="solr.SearchHandler"> <lst name="defaults"> <str name="defType">edismax</str> <str name="qf">title^1.5 content^1.0</str> <str name="rows">100</str> <str name="fl">*,score</str>
<!-- Enable clustering. --> <bool name="clustering">true</bool> <!-- enable clustering --> <bool name="clustering.results">true</bool> <!-- cluster search results, not the collection --> <str name="clustering.engine">default</str> <!-- use the default engine -->
<!-- Solr-to-Carrot2 field mapping. --> <str name="carrot.url">name</str> <!-- unique ID field, doesn't have to be an URL --> <str name="carrot.title">title</str> <!-- document title field. --> <str name="carrot.snippet">content</str> <!-- document "contents" field --> </lst>
<!-- Attach clustering as the last processing component. --> <arr name="last-components"> <str>clustering</str> </arr> </requestHandler> |
config1_2 (search handler returning a subset of fields)
<requestHandler name="/config1_2" class="solr.SearchHandler"> <lst name="defaults"> <str name="defType">edismax</str> <str name="qf">title^1.5 content^1.0</str> <str name="rows">100</str>
<!--只显示name,title,content太大,不显示--> <str name="fl">name,title,score</str>
<bool name="clustering">true</bool> <bool name="clustering.results">true</bool> <str name="clustering.engine">default</str>
<str name="carrot.url">name</str> <str name="carrot.title">title</str> <str name="carrot.snippet">content</str> </lst>
<arr name="last-components"> <str>clustering</str> </arr> </requestHandler> |
config1_3(search handler returning contextual snippets)
<requestHandler name="/config1_3" class="solr.SearchHandler"> <lst name="defaults"> <str name="defType">edismax</str> <str name="qf">title^1.5 content^1.0</str> <str name="rows">100</str>
<str name="fl">name,title,score</str>
<!—对内容字段高亮 --> <bool name="hl">true</bool> <str name="hl.fl">content</str> <!-- Disable highlight wrapping. --> <str name="hl.simple.pre"><!-- --></str> <str name="hl.simple.post"><!-- --></str> <str name="f.content.hl.snippets">3</str> <!-- max 3 snippets of 200 chars. --> <str name="f.content.hl.fragsize">200</str>
<bool name="clustering">true</bool> <bool name="clustering.results">true</bool> <str name="clustering.engine">default</str>
<str name="carrot.url">name</str> <str name="carrot.title">title</str> <str name="carrot.snippet">content</str> </lst>
<arr name="last-components"> <str>clustering</str> </arr> </requestHandler> |
config2_1(search handler clustering query-in-context snippets)
<requestHandler name="/config2_1" class="solr.SearchHandler"> <lst name="defaults"> <str name="defType">edismax</str> <str name="qf">title^1.5 content^1.0</str> <str name="rows">100</str>
<str name="fl">name,title,score</str>
<bool name="clustering">true</bool> <bool name="clustering.results">true</bool> <str name="clustering.engine">default</str>
<str name="carrot.url">name</str> <str name="carrot.title">title</str> <str name="carrot.snippet">content</str>
<!--只聚类高亮的段 --> <str name="carrot.produceSummary">true</str> <!--只分析内容中三段 --> <str name="carrot.summarySnippets">3</str> </lst>
<arr name="last-components"> <str>clustering</str> </arr> </requestHandler> |
访问
http://localhost:8983/solr/example/config1_1?q=memory&wt=xml&indent=true
5.集成solr到carrot2的网站
准备Tomcat和carrot2-webapp-3.9.2
将carrot2-webapp-3.9.2.war解压,修改F:\solr\apache-tomcat-6.0.39\webapps\carrot2-webapp-3.9.2\WEB-INF\suites中suite-webapp.xml文件
<component-suite> <sources> <source component-class="org.carrot2.source.solr.SolrDocumentSource" id="solr" attribute-sets-resource="source-solr-attributes.xml"> <label>Solr</label> <title>Solr Search Engine</title> <icon-path>icons/solr.png</icon-path> <mnemonic>s</mnemonic> <description>Solr document source queries an instance of Apache Solr search engine.</description> <example-queries> <example-query>test</example-query> <example-query>solr</example-query> </example-queries> </source> </sources> <!-- Algorithms --> <include suite="algorithm-passthrough.xml"></include> </component-suite> |
修改source-solr-attributes.xml文件
<attribute-sets default="overridden-attributes"> <attribute-set id="overridden-attributes"> <value-set> <label>overridden-attributes</label> <attribute key="SolrDocumentSource.serviceUrlBase"> <value value="http://localhost:8983/solr/example/config1_2"/> </attribute> <attribute key="SolrDocumentSource.solrSummaryFieldName"> <value value="content"/> </attribute> <attribute key="SolrDocumentSource.solrTitleFieldName"> <value value="title"/> </attribute> <attribute key="SolrDocumentSource.solrUrlFieldName"> <value value="name"/> </attribute> <!-- Proxy clusters from Solr. Link on 'name' field. --> <attribute key="SolrDocumentSource.solrIdFieldName"> <value value="name"/> </attribute> <attribute key="SolrDocumentSource.readClusters"> <value value="true"/> </attribute> </value-set> </attribute-set> </attribute-sets> |
6.启动Tomcat
将carrot2-webapp-3.9.2放到tomcat的webapps下并启动tomcat
访问地址http://localhost:8080/carrot2-webapp-3.9.2
搜索memory
Carrot2的图形界面
Apache SOLR and Carrot2集成的更多相关文章
- 玩转大数据系列之Apache Pig如何与Apache Solr集成(二)
散仙,在上篇文章中介绍了,如何使用Apache Pig与Lucene集成,还不知道的道友们,可以先看下上篇,熟悉下具体的流程. 在与Lucene集成过程中,我们发现最终还要把生成的Lucene索引,拷 ...
- solr服务中集成IKAnalyzer中文分词器、集成dataimportHandler插件
昨天已经在Tomcat容器中成功的部署了solr全文检索引擎系统的服务:今天来分享一下solr服务在海量数据的网站中是如何实现数据的检索. 在solr服务中集成IKAnalyzer中文分词器的步骤: ...
- [Solr] (源) Solr与MongoDB集成,实时增量索引
一. 概述 大量的数据存储在MongoDB上,需要快速搜索出目标内容,于是搭建Solr服务. 另外一点,用Solr索引数据后,可以把数据用在不同的项目当中,直接向Solr服务发送请求,返回xml.js ...
- Solr与MongoDB集成,实时增量索引
Solr与MongoDB集成,实时增量索引 一. 概述 大量的数据存储在MongoDB上,需要快速搜索出目标内容,于是搭建Solr服务. 另外一点,用Solr索引数据后,可以把数据用在不同的项目当中, ...
- Apache Solr 初级教程(介绍、安装部署、Java接口、中文分词)
Python爬虫视频教程零基础小白到scrapy爬虫高手-轻松入门 https://item.taobao.com/item.htm?spm=a1z38n.10677092.0.0.482434a6E ...
- Apache Solr Velocity模板注入RCE漏洞复现
Apache Solr Velocity模板注入RCE漏洞复现 一.Apache Solr介绍 Solr是一个独立的企业级搜索应用服务器,它对外提供类似于web-service的API接口,用户可以通 ...
- 26.Apache Solr RCE
多事之秋,刚爆出来shiro的RCE,紧接着solr服务器就出了RCE 自从漏洞爆出来已经一段时间,复现漏洞多如牛毛,我这里来水一篇 漏洞简介 什么是solr服务器? Solr是一个独立的企业级搜索应 ...
- 【漏洞复现】Apache Solr via Velocity template远程代码执行
0x01 概述 Solr简介 Apache Solr 是一个开源的企业级搜索服务器.Solr 使用 Java 语言开发,主要基于 HTTP 和 Apache Lucene 实现.Apache Solr ...
- CVE-2019-0193 Apache solr velocity模块漏洞
Solr简单介绍 Solr是建立在Apache Lucene ™之上的一个流行.快速.开放源代码的企业搜索平台. Solr具有高度的可靠性,可伸缩性和容错能力,可提供分布式索引,复制和负载平衡查询,自 ...
随机推荐
- 引用数据类型 Scanner Random
Scanner类 数据类型 变量名 = new 数据类型(); 每种引用数据类型都有其功能,我们可以调用该类型实例的功能. 变量名.方法名(); Scanner类是引用数据类型的一种,我们可以使 ...
- luoguP1154 奶牛分厩 [数论]
题目描述 农夫约翰有N(1<=N<=5000)头奶牛,每头奶牛都有一个唯一的不同于其它奶牛的编号Si,所有的奶牛都睡在一个有K个厩的谷仓中,厩的编号为0到K-1.每头奶牛都知道自己该睡在哪 ...
- golang中net/http包的简单使用
一.介绍 http包提供了http客户端和服务端的实现 Get,Head,Post和PostForm函数发出http.https的请求 程序在使用完回复后必须关闭回复的主体 #简单的访问网站,由于没有 ...
- H5 回到顶部按钮
//这里我用的是svg,所以代码老长了,可以把svg部分换成自己的图片什么的$(function(){ var obj = $('<div style="width:1.3rem;po ...
- Window中在Intellij idea开发时常用快捷键
以下idea中的快捷键是在window 7中确认过,如果快捷键不起作用,可能是该快捷键被其它软件占用,或系统不同导致. 1.Ctrl + Z:撤回代码: 2.Ctrl + Shift + Z:恢复撤回 ...
- P1020 导弹拦截 /// DP Dilworth定理 LIS、LDS优化
题目大意: https://www.luogu.org/problemnew/show/P1020 Dliworth有两个互相对偶的定理:U的链划分使用的最少集合数,等于它的最大反链长度.(1)U的反 ...
- vue2.0装jquery
1.在项目目录下 cnpm install --save jquery 2.在webpack.base.conf.js中加入 var webpack = require('webpack') 3.在p ...
- java_瞬时
瞬时(Instant): 方法: public class InstantTest01 { public static void main(String[] args){ //静态方法,返回utc上的 ...
- C++单纯的指针传参的问题
C++指针传参也是单纯的复制一份地址,如下代码: #define _CRT_SECURE_NO_WARNINGS #include<iostream> using namespace st ...
- CoreML 简单使用
今天简单使用了下CoreML , 我的这个模型功能主要是 打开摄像头,然后对准物体,会自动帮我们识别摄像头中的物体,并且给我们大概的百分比值 代码如下: @IBAction func startCli ...