apache solr helloworld
来源:互联网 发布:新疆世纪矩阵官方网站 编辑:程序博客网 时间:2024/05/21 09:02
现在Solr的版本是3.1,与Lucene Java开始同版本号发布。
Hello, World!
从Solr的官网下载Solr的包,我们就挑一个国内的镜像吧,http://labs.renren.com/apache-mirror//lucene/solr/3.1.0/,可以看到,这里有一个是源码包,一个是可执行包。我们就先下载可执行包apache-solr-3.1.0.zip 。
把包解开。可以看到里面有几个文件夹:
client:用来存放Solr客户端的文件夹,目前里面值存放了一个Ruby的客户端。
contrib:Solr的强劲插件所用到得依赖Jar包
dist:Solr的发布文件,包括Solr的插件
docs:文档和Javadoc
example:示例
好,先不多说,直奔主题:命令行进入example文件夹,
- E:/tony/libDoc/Java/Lucene/apache-solr-3.1.0/example>java -jar start.jar
如无意外,可以看到Jetty的启动过程以及Solr的初始化过程:
在命令行最后一行显示的内容应该是:
- 2011-5-10 10:12:19 org.apache.solr.core.SolrCore registerSearcher
- 信息: [] Registered new searcher Searcher@50903025 main
值得注意的是,Jetty帮我们打开的端口是8983, 这时候,我们应该可以从浏览器里面浏览 http://localhost:8983/solr/。
我们从http://localhost:8983/solr/admin/stats.jsp#core可以看到
- numDocs : 0
表示说我们的Solr是干净的,什么也没有。
好,现在网Solr里面塞点数据,命令行进入 solr解压文件夹/example/exampledocs
- E:/tony/libDoc/Java/Lucene/apache-solr-3.1.0/example/exampledocs>java -jar post.
- jar *.xml
- SimplePostTool: version 1.3
- SimplePostTool: POSTing files to http://localhost:8983/solr/update..
- SimplePostTool: POSTing file gb18030-example.xml
- SimplePostTool: POSTing file hd.xml
- SimplePostTool: POSTing file ipod_other.xml
- SimplePostTool: POSTing file ipod_video.xml
- SimplePostTool: POSTing file mem.xml
- SimplePostTool: POSTing file monitor.xml
- SimplePostTool: POSTing file monitor2.xml
- SimplePostTool: POSTing file mp500.xml
- SimplePostTool: POSTing file sd500.xml
- SimplePostTool: POSTing file solr.xml
- SimplePostTool: POSTing file utf8-example.xml
- SimplePostTool: POSTing file vidcard.xml
- SimplePostTool: COMMITting Solr index changes..
这时,我们再看看Solr里面的文档数:
- numDocs : 17
到这里,我们已经建立了Solr的demo,我们现在来试试搜索:
回到http://localhost:8983/solr/admin/,在的Query String:文本框里面填入
- name:apple
点击search button,会从定向到 http://localhost:8983/solr/select/?q=name%3Aapple&version=2.2&start=0&rows=10&indent=on
结果是一个XML文档
- <?xml version="1.0" encoding="UTF-8"?>
- <response>
- <lst name="responseHeader">
- <int name="status">0</int>
- <int name="QTime">6</int>
- <lst name="params">
- <str name="indent">on</str>
- <str name="start">0</str>
- <str name="q">name:apple</str>
- <str name="version">2.2</str>
- <str name="rows">10</str>
- </lst>
- </lst>
- <result name="response" numFound="1" start="0">
- <doc>
- <arr name="cat"><str>electronics</str><str>music</str></arr>
- <arr name="features"><str>iTunes, Podcasts, Audiobooks</str><str>Stores up to 15,000 songs, 25,000 photos, or 150 hours of video</str><str>2.5-inch, 320x240 color TFT LCD display with LED backlight</str>
- <str>Up to 20 hours of battery life</str><str>Plays AAC, MP3, WAV, AIFF, Audible, Apple Lossless, H.264 video</str><str>Notes, Calendar, Phone book, Hold button, Date display, Photo wallet, Built-in games, JPEG photo playback, Upgradeable firmware, USB 2.0 compatibility, Playback speed control, Rechargeable capability, Battery level indication</str></arr>
- <str name="id">MA147LL/A</str>
- <bool name="inStock">true</bool>
- <str name="includes">earbud headphones, USB cable</str>
- <str name="manu">Apple Computer Inc.</str>
- <date name="manufacturedate_dt">2005-10-12T08:00:00Z</date>
- <str name="name">Apple 60 GB iPod with Video Playback Black</str>
- <int name="popularity">10</int>
- <float name="price">399.0</float>
- <str name="store">37.7752,-100.0232</str>
- <float name="weight">5.5</float>
- </doc>
- </result>
- </response>
这样,Solr经过全文检索,返回给我们一条结果,耗时6ms。
- apache solr helloworld
- Apache Solr
- apache solr
- apache+solr
- Apache Solr
- Solr 1 Helloworld
- apache helloworld
- Apache Solr 介绍
- Apache Solr 剖析
- 搜索引擎 apache-solr
- apache solr 标准安装
- Apache Solr 启动
- apache solr 安装
- Solr with Apache Tomcat
- Apache Solr 初级教程
- apache solr EmbeddedSolrServer
- apache 搜索引擎solr试用
- 如何监控 Apache Solr ?
- 自己的博客——liming blog 黎明的CSDN博客
- oracle非法关机数据库无法启动ORA-00600: [kcratr1_lostwrt],解决办法
- 常用设计模式总结--适配器模式
- 如何在 Windows 恢复环境中使用 Bootrec.exe 工具解决和修复 Windows Vista 中的启动问题
- startup,startup mount,startup nomount之间的区别
- apache solr helloworld
- CSS中Position为absolute的时候的建议!
- MySql错误代码1045的解决方案
- Linux下ps查找进程用kill终止命令
- 从今天起开始努力成为一名程序员!
- SQL Server 2008数据库重命名方法
- 获取Internet Explorer版本
- 用HTML,Javascript,CSS开发桌面应用
- Windows GUI stuffs need to be memorized