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

[经验分享] 基于apache lucene的solr站内搜索引擎搭配手记

[复制链接]

尚未签到

发表于 2015-7-17 11:58:25 | 显示全部楼层 |阅读模式



    基于apache lucene的solr站内搜索引擎搭配手记
   [ 预备警员.10078 @ 2009-03-23 17:15:30 ]

由于工作关系,断断续续的测试了solr的搭建和配置的工作一周,这个企业级的全站搜索工具,应该说是专业搜索引擎的有益补充,之所以存在这样的工具,可 能会是,再好的搜索引擎都很难对一个站点的所有有价值的内容进行及时有效全部的索引,并按一定的规则组织和呈现给调用者。

1. 初尝试lucene,lucene在apache的站点可以下载到: http://lucene.apache.org/

下载到一个最近的包之后,解压,里面带着的一个example,可以很容易的就开展起来,尤其负责lucene的index和search服务,通过 Indexer 和 Searcher 两个对象,可以在命令下实现建立索引和查询,其余接口也都较为丰富,由于接下来会重点说一下基于 lucene的 solr的配置,所以底层的lucene怎么来配选,简略一下。

lucene有较为丰富的文档,可以在线翻阅,同时lucene的贡献者在搜索领域有几项专利,也是这方面的专家,相信其所设计的一些底层应该没有问题。

2. solr的安装与配置

2.1 现有平台的环境
openSuSE Linux 10, DELL PE 2950的机器,上面部署了 Apache+Resin+MySQL 的应用。

针对Solr往现有平台的迁入,主要动了如下几个地方:

2.2.1
下载安装包:http://www.apache.org/dyn/closer.cgi/lucene/solr/
到一个叫做 /opt/src/ (没有的话,先 mkdir -p /opt/src 一个)下面

shell> cd /opt/src
shell> wget "http://apache.mirror.phpchina.com/lucene/solr/1.3.0/apache-solr-1.3.0.tgz"
shell> tar xzvf apache-solr-1.3.0.tgz
shell> cd /opt/src/apache-solr-1.3.0

这样就解开了压缩包并备用状态, 里面有个jetty的 WEB Server, 与solr结合的较好,可以马上就开始。 下面是从 apache solr wiki的站点cp的 get started内容,贴在这里备查参考(http://lucene.apache.org/solr /tutorial.html#Getting+Started):

Overview
This document covers the basics of running Solr using an example schema, and some sample data.

Requirements
To follow along with this tutorial, you will need...

1.Java 1.5 or greater. Some places you can get it are from Sun, IBM, or BEA.
Running java -version at the command line should indicate a version number starting with 1.5.
2.A Solr release.
3.FireFox or Mozilla is the preferred browser to view the admin pages, as the current stylesheet doesn't look good on Internet Explorer.
Getting Started
Please run the browser showing this tutorial and the Solr server on the same machine so tutorial links will correctly point to your Solr server.

Begin by unziping the Solr release and changing your working directory to be the "example" directory. (Note that the base directory name may vary with the version of Solr downloaded.)

chrish@asimov:~solr$ ls
solr-nightly.zip
chrish@asimov:~solr$ unzip -q solr-nightly.zip
chrish@asimov:~solr$ cd solr-nightly/example/
Solr can run in any Java Servlet Container of your choice, but to simplify this tutorial, the example index includes a small installation of Jetty. In order to compile JSPs, this version of Jetty requires that you run "java" from a JDK, not from a JRE.

To launch Jetty with the Solr WAR, and the example configs, just run the start.jar ...

chrish@asimov:~/solr/example$ java -jar start.jar
1 [main] INFO org.mortbay.log - Logging to org.slf4j.impl.SimpleLogger@1f436f5 via org.mortbay.log.Slf4jLog
334 [main] INFO org.mortbay.log - Extract jar:file:/home/chrish/solr/example/webapps/solr.war!/ to /tmp/Jetty__solr/webapp
Feb 24, 2006 5:54:52 PM org.apache.solr.servlet.SolrServlet init
INFO: user.dir=/home/chrish/solr/example
Feb 24, 2006 5:54:52 PM org.apache.solr.core.SolrConfig
INFO: Loaded Config solrconfig.xml

...

1656 [main] INFO org.mortbay.log - Started SelectChannelConnector @ 0.0.0.0:8983
This will start up the Jetty application server on port 8983, and use your terminal to display the logging information from Solr.

You can see that the Solr is running by loading http://localhost:8983/solr/admin/ in your web browser. This is the main starting point for Administering Solr.

Indexing Data
Your Solr server is up and running, but it doesn't contain any data. You can modify a Solr index by POSTing XML Documents containing instructions to add (or update) documents, delete documents, commit pending adds and deletes, and optimize your index.

The exampledocs directory contains samples of the types of instructions Solr expects, as well as a java utility for posting them from the command line (a post.sh shell script is also available, but for this tutorial we'll use the cross-platform Java client).

To try this, open a new terminal window, enter the exampledocs directory, and run "java -jar post.jar" on some of the XML files in that directory, indicating the URL of the Solr server:

chrish@asimov:~/solr/example/exampledocs$ java -jar post.jar solr.xml monitor.xml
SimplePostTool: version 1.2 ..

运维网声明 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-87645-1-1.html 上篇帖子: solr&lucene3.6.0源码解析(二) 下篇帖子: Solr索引数据库数据
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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