ITeye博客

Solr 使用入门介绍

xiaoyezi1128 · 2009-12-31 14:11 · solr · 编程语言 · Solr · 应用服务器 · Apache · 搜索引擎 · Tomcat · Markdown

« 在 Grails 中使用 TinyMCE 富文本编辑器 安装 HAProxy 配置负载均衡 » Solr 使用入门介绍,以搜索论坛帖子为示例 发表于:2009年5月27日 | 分类:Search | 标签: solr | views(1,581) 版权信息: 可以任意转载, 转载时请务必以超链接形式标明文章原文出处, 即下面的声明. 原文出处:http://blog.chenlb.com/2009/05/apache-solr-quick-start-and-demo.html 前些日子做了个 apache solr 应用的入门介绍,也在博客记录下,方便新手看看。以搜索论坛帖子为示例。 1、先下载 Apache Solr 1.3 http://apache.etoak.com/lucene/solr/1.3.0/apache-solr-1.3.0.zip,解压到如 E:\apache-solr-1.3.0。 2、下载 Apache Tomcat 6.0.18 http://labs.xiaonei.com/apache-mirror/tomcat/tomcat-6/v6.0.18/bin/apache-tomcat-6.0.18.zip,解压到如 E:\apache-tomcat-6.0.18。 3、solr 安装到 tomcat。修改 E:\apache-tomcat-6.0.18\conf\server.xml,加个 URIEncoding="UTF-8",把 8080 的那一块改为: 把下面的内容保存到 E:\apache-tomcat-6.0.18\conf\Catalina\localhost\solr.xml,没有这个目录自行创建。 solr 的更多方式请看:solr install 4、现在安装好,启动 tomcat,并打开 http://localhost:8080/solr/admin/ 看看界面。 5、为搜索论坛帖子应用设计索引结构: 字段 说明 id 帖子 id user 发表用户名或UserId title 标题 content 内容 timestamp 发表时间 text 把标题和内容放到这里,可以用同时搜索这些内容。 6、上面的索引结构告诉 solr,把下面的内容覆盖 E:\apache-solr-1.3.0\example\solr\conf\scheam.xml,(可以先备份这文件,方便以后看官方示例): id text id text 7、重启 tomcat,然后手动在 E:\apache-solr-1.3.0\example\exampledocs 创建两个 xml 数据文件。分别保存为 demo-doc1.xml 和 demo-doc2.xml: 1 chenlb solr 应用演讲 这一小节是讲提交数据给服务器做索引,这里有一些数据,如:服务器,可以试查找它。 1 chenlb solr 应用演讲 这一小节是讲提交数据给服务器做索引,这里有一些数据,如:服务器,可以试查找它。 2 bory.chan 搜索引擎 搜索服务器那边有很多数据。 2009-02-18T00:00:00Z 3 other 这是什么 你喜欢什么运动?篮球? 2009-02-18T12:33:05.123Z 2 bory.chan 搜索引擎 搜索服务器那边有很多数据。 2009-02-18T00:00:00Z 3 other 这是什么 你喜欢什么运动?篮球? 2009-02-18T12:33:05.123Z 8、提交数据做索引,到 E:\apache-solr-1.3.0\example\exampledocs,运行: E:\apache-solr-1.3.0\example\exampledocs>java -Durl=http://localhost:8080/solr/update -Dcommit=yes -jar post.jar demo-doc*.xml SimplePostTool: version 1.2 SimplePostTool: WARNING: Make sure your XML documents are encoded in UTF-8, other encodings are not currently supported SimplePostTool: POSTing files to http://localhost:8080/solr/update.. SimplePostTool: POSTing file demo-doc1.xml SimplePostTool: POSTing file demo-doc2.xml SimplePostTool: COMMITting Solr index changes..9、查看搜索结果: 所有内容 http://localhost:8080/solr/select/?q=*%3A*&version=2.2&start=0&rows=10&indent=on 0 0 on 0 *:* 10 2.2 这一小节是讲提交数据给服务器做索引,这里有一些数据,如:服务器,可以试查找它。 1 2009-05-27T04:07:54.89Z solr 应用演讲 chenlb 搜索服务器那边有很多数据。 2 2009-02-18T00:00:00Z 搜索引擎 bory.chan 你喜欢什么运动?篮球? 3 2009-02-18T12:33:05.123Z 这是什么 other 0 0 on 0 *:* 10 2.2 这一小节是讲提交数据给服务器做索引,这里有一些数据,如:服务器,可以试查找它。 1 2009-05-27T04:07:54.89Z solr 应用演讲 chenlb 搜索服务器那边有很多数据。 2 2009-02-18T00:00:00Z 搜索引擎 bory.chan 你喜欢什么运动?篮球? 3 2009-02-18T12:33:05.123Z 这是什么 other bory.chan 用户的:http://localhost:8080/solr/select/?q=user%3Abory.chan&version=2.2&start=0&rows=10&indent=on 0 0 on 0 user:bory.chan 10 2.2 搜索服务器那边有很多数据。 2 2009-02-18T00:00:00Z 搜索引擎 bory.chan 0 0 on 0 user:bory.chan 10 2.2 搜索服务器那边有很多数据。 2 2009-02-18T00:00:00Z 搜索引擎 bory.chan 时间 http://localhost:8080/solr/select/?q=timestamp%3A%5B%222009-02-18T00%3A00%3A00Z%22+TO+%222009-02-19T00%3A00%3A00Z%22%5D&version=2.2&start=0&rows=10&indent=on 0 16 on 0 timestamp:["2009-02-18T00:00:00Z" TO "2009-02-19T00:00:00Z"] 10 2.2 搜索服务器那边有很多数据。 2 2009-02-18T00:00:00Z 搜索引擎 bory.chan 你喜欢什么运动?篮球? 3 2009-02-18T12:33:05.123Z 这是什么 other 0 16 on 0 timestamp:["2009-02-18T00:00:00Z" TO "2009-02-19T00:00:00Z"] 10 2.2 搜索服务器那边有很多数据。 2 2009-02-18T00:00:00Z 搜索引擎 bory.chan 你喜欢什么运动?篮球? 3 2009-02-18T12:33:05.123Z 这是什么 other 常用的 solr 查询参数请看:solr 查询参数说明 简单的示例已经完成了,索引文件(默认)会在 CWD/solr/data/index 目录下,要改为 solr.home/data目录下,在 F:\apache-solr-1.3.0\example\solr\conf\solrconfig.xml 把 dataDir 注释掉,如: 说明:上面没有使用中文分词,用官方的 CJK 分词,另外有 mmseg4j 中文分词的示例,请看:solr 中文分词 mmseg4j 使用例子

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。