solr学习问题

一、下载
下载目录:http://apache.fayea.com/lucene/solr/6.5.0/
下载zip包地址:http://apache.fayea.com/lucene/solr/6.5.0/solr-6.5.0.zip
二、安装与启动
# 解压zip包
unzip solr-6.5.0.zip
#进入solr-6.5.0目录
cd solr-6.5.0
#启动
bin/solr start -e cloud -noprompt
#访问地址为:http://localhost:8983/solr/
#Solr现在将运行两个“节点”,一个在端口7574上,一个在端口8983上。自动创建一个集合gettingstarted,两个分片集合,每个都有两个副本
三、添加索引
1、添加本地文件到索引
#getstarted:要索引到的集合的名称
#docs/:文件目录,此处为相对路径
bin/post -c getstarted docs/
2、添加指定目录的指定类型文件到索引
#添加本地文件目录中的xml文件到索引
bin/post -c gettingstarted example/exampledocs/*.xml
3、添加json数据到索引
bin/post -c gettingstarted example/exampledocs/books.json
4、添加csv表格数据到索引
bin/post -c gettingstarted example/exampledocs/books.csv
5、添加数据库数据到索引
四、更新索引
#删除索引
bin/post -c gettingstarted -d "<delete><id>978-0641723445</id></delete>"
五、搜索

Solr可以通过REST客户端,cURL,wget,Chrome POSTMAN等查询,以及通过可用于许多编程语言的本机客户端查询。

1、单个搜索(basics)
#wt代表返回的数据格式如json、xml
#q代表查询的条件
#fl表示返回的字段,不传默认为索引字段
#curl方式
curl "http://localhost:8983/solr/gettingstarted/select?indent=on&q=*:*&wt=json"
#查询id为0553293354的数据
curl "http://localhost:8983/solr/gettingstarted/select?wt=json&indent=true&q=id:0553293354"
#查询id为0553293354的数据,只返回字段name
curl "http://localhost:8983/solr/gettingstarted/select?wt=json&indent=true&q=id:0553293354&fl=name"
#查询
2、短语查询(Phrase search)
#查询条件到如果有空格需要转义
#查询字段中含有CORSAIR XMS的索引数据
curl "http://localhost:8983/solr/gettingstarted/select?wt=json&indent=true&q=\"CORSAIR+XMS\""
3、组合查询
#查询索引中既包含Maxtor又包含2B920的索引数据
#%2B为+的转义
curl "http://localhost:8983/solr/gettingstarted/select?wt=json&indent=true&q=%2BMaxtor+%2B920"
#查询索引中包含two但不包含one的所有数据
curl "http://localhost:8983/solr/gettingstarted/select?wt=json&indent=true&q=%2Btwo+-one"
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值