solr 5.0.0 新手快速入门



参考文档:https://cwiki.apache.org/confluence/display/solr/Getting+Started

环境:
CentOS 6.5, JDK 1.7, Solr5.0.0

一、standalone模型的安装、索引、搜索

1. 下载 Solr 5.0.0
资源地址:http://lucene.apache.org/solr/
#注意: Solr 5.0.0 必需JRE 1.7或者以上版本

2. 解压缩 Solr 5.0.0
tar zxf solr-5.0.0.tgz

3. 启动服务
bin/solr start
#注意:默认以后台进程启动服务,并监听在8983端口

4. 检查服务状态
bin/solr status

http://localhost:8983/solr/  #访问Solr管理界面

5. 创建core
bin/solr create -c gettingstarted
#创建一个gettingstarted的core, 并且scheme为data-driven(自动猜测数据类型)

6. 增加文档到索引
bin/post -c gettingstarted example/exampledocs/*.json
#提交example/exampledocs目录下所有的JSON文档到gettingstarted core

7. 搜索文档
直接构造带有搜索参数的URL即可

eg.
http://localhost:8983/solr/gettingstarted/select?q=video
#搜索gettingstarted core中所有文档字段中包含'video'的文档

http://localhost:8983/solr/gettingstarted/select?q=video&fl=id,name,price
#搜索gettingstarted core中所有文档字段中包含'video'的文档,并且每篇文档只返回id,name,price三个字段

http://localhost:8983/solr/gettingstarted/select?q=name:black
#搜索gettingstarted core中name字段包含'black'的文档

http://localhost:8983/solr/gettingstarted/select?q=price:[0%20TO%20400]&fl=id,name,price
#搜索gettingstarted core中price字段在0到400区间的文档,并且每篇文档只返回id,name,price三个字段

http://localhost:8983/solr/gettingstarted/select?q=price:[0%20TO%20400]&fl=id,name,price&facet=true&facet.field=cat
#搜索gettingstarted core中price字段在0到400区间的文档,每篇文档只返回id,name,price三个字段,并按照cat字段进行facet搜索

http://localhost:8983/solr/gettingstarted/select?q=price:0%20TO%20400&fl=id,name,price&facet=true&facet.field=cat&fq=cat:software
#搜索gettingstarted core中price字段在0到400区间的文档,每篇文档只返回id,name,price三个字段,按照cat字段进行facet搜索,并过滤返回cat字段为'software'的文档


二、bin/solr脚本常用操作

bin/solr start #开启solr服务,默认后台运行
bin/solr start -f #前台启动solr服务
bin/solr -help #查看bin/solr使用帮助
bin/solr start -help #查看bin/solr start使用帮助
bin/solr stop -p 8983 #停止8983端口上的solr服务,需要指定端口
bin/solr stop -all #停止所有端口上的solr服务
bin/solr status #查看solr服务运行状态
bin/solr create -c <name> #创建<name>的core
bin/solr create -help #查看bin/solr create的使用帮助



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值