apache 搜索引擎solr试用
来源:互联网 发布:淘宝买进口保健品 编辑:程序博客网 时间:2024/05/20 13:18
solr是apache旗下的开源搜索服务器,基于lucene搜索引擎。目前是apache的lucene项目下的子项目。solr的安装配置已经相当简单。所以,看起来像google那样复杂的搜索引擎技术,也可以不费很大力气的情况下,实现一个小型版。目前solr是企业级搜索服务器,最新版4.0alpha。
下载
[zhouhh@Hadoop48 ~]$ wget http://labs.renren.com/apache-mirror/lucene/solr/4.0.0-ALPHA/apache-solr-4.0.0-ALPHA.tgz
Length: 105132366 (100M) [application/x-gzip]
[zhouhh@Hadoop48 ~]$ tar zxvf apache-solr-4.0.0-ALPHA.tgz
启动solr
[zhouhh@Hadoop48 ~]$ cd apache-solr-4.0.0-ALPHA/example/
[zhouhh@Hadoop48 example]$ java -jar startjar
用浏览器访问8983端口,可以看到solr已经运行。但是因为没有索引信息,所以查询不到东西。
http://hadoop48:8983/solr/
添加内容
另起一个命令行窗口,进入exampledocs目录,添加solr.xml和monitor.xml两个文件到搜索引擎。
[zhouhh@Hadoop48 exampledocs]$ java -jar post.jar solr.xml monitor.xml
看一下这两个文件什么内容:
[zhouhh@Hadoop48 exampledocs]$ cat solr.xml
<add>
<doc>
<field name=”id”>SOLR1000</field>
<field name=”name”>Solr, the Enterprise Search Server</field>
<field name=”manu”>Apache Software Foundation</field>
<field name=”cat”>software</field>
<field name=”cat”>search</field>
<field name=”features”>Advanced Full-Text Search Capabilities using Lucene</field>
<field name=”features”>Optimized for High Volume Web Traffic</field>
<field name=”features”>Standards Based Open Interfaces – XML and HTTP</field>
<field name=”features”>Comprehensive HTML Administration Interfaces</field>
<field name=”features”>Scalability – Efficient Replication to other Solr Search Servers</field>
<field name=”features”>Flexible and Adaptable with XML configuration and Schema</field>
<field name=”features”>Good unicode support: héllo (hello with an accent over the e)</field>
<field name=”price”>0</field>
<field name=”popularity”>10</field>
<field name=”inStock”>true</field>
<field name=”incubationdate_dt”>2006-01-17T00:00:00.000Z</field>
</doc>
</add>
[zhouhh@Hadoop48 exampledocs]$ cat monitor.xml
<add><doc>
<field name=”id”>3007WFP</field>
<field name=”name”>Dell Widescreen UltraSharp 3007WFP</field>
<field name=”manu”>Dell, Inc.</field>
<!– Join –>
<field name=”manu_id_s”>dell</field>
<field name=”cat”>electronics</field>
<field name=”cat”>monitor</field>
<field name=”features”>30″ TFT active matrix LCD, 2560 x 1600, .25mm dot pitch, 700:1 contrast</field>
<field name=”includes”>USB cable</field>
<field name=”weight”>401.6</field>
<field name=”price”>2199</field>
<field name=”popularity”>6</field>
<field name=”inStock”>true</field>
<!– Buffalo store –>
<field name=”store”>43.17614,-90.57341</field>
</doc></add>
查询
浏览器进入http://hadoop48:8983/solr/#/collection1/query
在q里面输入dell,wt选json得到:http://hadoop48:8983/solr/collection1/select?q=dell&wt=json&indent=true
{
“responseHeader”:{
“status”:0,
“QTime”:1,
“params”:{
“indent”:”true”,
“wt”:”json”,
“q”:”dell”}},
“response”:{“numFound”:1,”start”:0,”docs”:[
{
"id":"3007WFP",
"name":"Dell Widescreen UltraSharp 3007WFP",
"manu":"Dell, Inc.",
"manu_id_s":"dell",
"cat":["electronics",
"monitor"],
“features”:["30\" TFT active matrix LCD, 2560 x 1600, .25mm dot pitch, 700:1 contrast"],
“includes”:”USB cable”,
“weight”:401.6,
“price”:2199.0,
“price_c”:”2199,USD”,
“popularity”:6,
“inStock”:true,
“store”:”43.17614,-90.57341″,
“_version_”:1406367184436854784}]
}}
如果输入solr,得到
http://hadoop48:8983/solr/collection1/select?q=solr&wt=json&indent=true
{
“responseHeader”:{
“status”:0,
“QTime”:1,
“params”:{
“indent”:”true”,
“wt”:”json”,
“q”:”solr”}},
“response”:{“numFound”:1,”start”:0,”docs”:[
{
"id":"SOLR1000",
"name":"Solr, the Enterprise Search Server",
"manu":"Apache Software Foundation",
"cat":["software",
"search"],
“features”:["Advanced Full-Text Search Capabilities using Lucene",
"Optimized for High Volume Web Traffic",
"Standards Based Open Interfaces - XML and HTTP",
"Comprehensive HTML Administration Interfaces",
"Scalability - Efficient Replication to other Solr Search Servers",
"Flexible and Adaptable with XML configuration and Schema",
"Good unicode support: héllo (hello with an accent over the e)"],
“price”:0.0,
“price_c”:”0,USD”,
“popularity”:10,
“inStock”:true,
“incubationdate_dt”:”2006-01-17T00:00:00Z”,
“_version_”:1406367184423223296}]
}}
输入google得到为空:
http://hadoop48:8983/solr/collection1/select?q=google&wt=json&indent=true
{
“responseHeader”:{
“status”:0,
“QTime”:1,
“params”:{
“indent”:”true”,
“wt”:”json”,
“q”:”google”}},
“response”:{“numFound”:0,”start”:0,”docs”:[]
}}
中文支持
utf8完美支持。编辑一个my.xml
[zhouhh@Hadoop48 exampledocs]$ vi my.xml
提交到搜索引擎:
[zhouhh@Hadoop48 exampledocs]$ java -jar post.jar my.xml
全文搜索比如,“醒目”,http://hadoop48:8983/solr/collection1/select?q=%E9%86%92%E7%9B%AE&wt=xml&indent=true
得到:
参考:
https://builds.apache.org/job/Solr-trunk/javadoc/doc-files/tutorial.html 官方教程
http://www.ibm.com/developerworks/cn/java/j-solr1/ 使用 Apache Solr 实现更加灵巧的搜索
http://lucene.apache.org/solr/
http://www.originsoft.net/archives/32 Apache Solr 初级教程(介绍、安装部署、Java接口、中文分词)
Solr的配置及从数据库建立索引
转载地址:http://abloz.com/2012/07/02/apache-search-engine-solr-trial.html
- apache 搜索引擎solr试用
- 搜索引擎 apache-solr
- 搜索引擎 Apache Solr
- apache solr 搜索引擎使用笔记
- 搜索引擎之---Apache solr的实现
- (搜索引擎之solr) Apache Solr – Facet介绍
- SOLR搜索引擎
- 搜索引擎-solr
- 3款搜索引擎试用
- Solr搜索引擎(1)Solr安装
- Apache Solr
- apache solr
- apache+solr
- Apache Solr
- Solr 企业级搜索引擎简介
- Solr 企业级搜索引擎简介
- magento 部署solr 搜索引擎
- 搜索引擎之solr小结
- Android学习笔记 - 蓝牙篇 (Bluetooth)
- vbox虚拟机和主机共享黏贴板
- oracle存储子程序
- 【数据结构】二叉堆与左偏树
- 抓包工具 wireshark的 name resolution 名称转换功能
- apache 搜索引擎solr试用
- oracle中在已有的表中增加或删除一列
- Preview of Qt 5 for Android
- 嵌入式系统开发工程师&嵌入式软件开发工程师
- 组件化:企业级大型项目必经之路
- poj2406
- 从下拉菜单设计细节看Amazon对用户体验的把握
- 如何解决 .git/rebase-apply still exists but mbox given
- SVN 状态标识的详解