Apache SOLR and Carrot2集成
1.环境
下载软件
名称 |
地址 |
solr-integration-strategies-gh-pages.zip |
https://github.com/carrot2/solr-integration-strategies |
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的图形界面
转载于:https://www.cnblogs.com/shm10/p/3700604.html
Apache SOLR and Carrot2集成相关推荐
- apache hadoop_通过Apache Hadoop大规模扩展Apache Solr实时实时索引
apache hadoop 播客的第22集是与Patrick Hunt的谈话 我们讨论了Apache Solr(上游)中的新工作,使它可以在Apache Hadoop上工作. Solr支持将其索引和事 ...
- 借助Apache Hadoop大规模扩展Apache Solr实时实时索引
播客的第22集是与Patrick Hunt的谈话 我们讨论了Apache Solr(上游)中的新工作,使它可以在Apache Hadoop上工作. Solr支持将其索引和事务日志文件写入和读取到HDF ...
- Apache Solr 4.0今日发布
经过了三年的开发努力,Apache Solr Server 4.0终于发布了. Apache Solr是流行的,速度极快,开源的NoSQL的搜索平台,来自于Apache Lucene项目.它的主要功能 ...
- Solr与MongoDB集成,实时增量索引[转]
http://www.123905.com/ 一. 概述 大量的数据存储在MongoDB上,需要快速搜索出目标内容,于是搭建Solr服务. 另外一点,用Solr索引数据后,可以把数据用在不同的项目当中 ...
- 使用Apache Solr对数据库建立索引(包括处理CLOB、CLOB)
以下资料整理自网络,觉的有必要合并在一起,这样方便查看.主要分为两部分,第一部分是对<db-data-config.xml>的配置内容的讲解(属于高级内容),第二部分是DataImport ...
- 使用Apache Solr对数据库建立索引(包括处理CLOB、CLOB)(转)
以下资料整理自网络,觉的有必要合并在一起,这样方便查看.主要分为两部分,第一部分是对<db-data-config.xml>的配置内容的讲解(属于高级内容),第二部分是DataImport ...
- 搜索引擎之---Apache solr的实现
Solr 是一种可供企业使用的.基于 Lucene 的搜索服务器,它支持层面搜索.命中醒目显示和多种输出格式.在这篇分两部分的文章中,Lucene Java™ 的提交人 Grant Ingersoll ...
- Apache Solr入门教程(初学者之旅)
2019独角兽企业重金招聘Python工程师标准>>> 写在前面:本文涉及solr入门的各方面,请逐行阅读,相信能帮助你对solr有个清晰全面的了解并能简单实用. 在Apache S ...
- Apache Solr schema.xml及solrconfig.xml文件中文注解
一.字段配置(schema) schema.xml位于solr/conf/目录下,类似于数据表配置文件, 定义了加入索引的数据的数据类型,主要包括type.fields和其他的一些缺省设置. 1.先来 ...
- apache solr velocity 注入远程命令执行漏洞 (cve-2019-17558)
Apache Solr 是一个开源的搜索服务器. 在其 5.0.0 到 8.3.1版本中,用户可以注入自定义模板,通过Velocity模板语言执行任意命令. 具体漏洞原理和POC可以参考: https ...
最新文章
- 2022THE重量级大学排名:97所内地高校上榜!
- java 三个参数的运算符,java – 三个参数运算符:局部变量可能尚未初始化
- python实现:旋转矩阵转换为四元数
- Modal提示框插件的使用
- Java 大数类BigInteger与BigDecimal详细介绍(配蓝桥杯例题讲解)
- P2619 [国家集训队2]Tree I
- 计算机组成原理——计算机系统的性能指标(机器字长、存储容量、运算速度)
- c语言作业系统输出超限,C语言网Online Judge系统支持语言和编译说明
- c#操作access,update语句不执行的解决办法
- TIOBE 4月编程语言排行榜:MATLAB即将跌出TOP 20
- 矩阵、优化理论常用记号
- nginx 子进程 woker process 启动失败的问题
- JAVA根据地点获取经纬度
- 热血格斗场(二分法+STL运用)
- 美团点评_给出两个字符串(可能包含空格),找出其中最长的公共连续子串,输出其长度。
- python 采用to_csv保存数据不覆盖原有数据到文件中
- 初秋最全的穿搭都在这里了!
- Shinobi开源监控项目安装
- DNS服务器未响应是什么意思
- Ubuntu修改交换空间(新增或扩容)
热门文章
- 非参数统计的Python实现——随机游程检验
- 产品配件类目税目分类_商品和服务税收分类编码
- 【工具分享】AWVS 13 Linux版
- java odbc 驱动_Java java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序...
- 微积分应用 计算机,微积分及其应用 P.D.Lax等著;林开亮
- ibm服务器aix系统查看cpu,IBM AIX系统硬件信息查看命令(shell脚本)
- Kali linux 全部版本镜像下载
- idea设置主题路径
- 《数据结构题集》习题解析
- Python参考手册(第4版)