举例:
curl http://solr-private/solr/private-main/select -d q="*:*" -d "starts=0" -d "rows=3" -d "sort=last_modified_date asc"
---添加索引
curl "http://hadoop03:8983/solr/tags/update?commit=true" -H "Content-Type: text/xml" --data-binary '98765432122'
curl "http://hadoop03:8983/solr/tags/update?commit=true" -H "Content-Type: text/xml" --data-binary '98765432122'
---删除索引
curl http://hadoop03:8983/solr/tags/update?commit=true -H "Content-Type: text/xml" --data-binary '987654321'
curl http://hadoop03:8983/solr/tags/update?commit=true -H "Content-Type: text/xml" --data-binary '987654321'
---更新索引 增加同时删除
curl http://hadoop03:8983/solr/tags/update/?commit=true -H "Content-Type: text/xml" --data-binary '171234';
---查询索引
curl http://localhost:8983/solr/tags/query -d 'q=*:*'
curl http://hadoop03:8983/solr/fx_tags/query -d 'q=*:*&fl=id'
---solr条件查询
curl http://localhost:8983/solr/fs_tags/query -d 'q=*:*&fq=fs1:*&fq=fs2:*&fq=fs3:*&fs4:*&fq=fs11:*&fq=fstatus:0'
--- 相关查询
curl http://localhost:8983/solr/fs_tags/query -d 'q=fstatus:1&fq=fs1:*' -d "fl=fstatus,fs1,id" -d "starts=10" -d "rows=3" -d "sort=id desc"
q:查询字符串,如查询所有,则 *:*
fq:filter query 在q查询结果中同时符合fq查询的,例如:q=Name:张三&fq=CreateDate:[20081001 TO 20091031],找关键字mm,并且CreateDate是20081001
fl: - 指定返回那些字段内容,用逗号或空格分隔多个。
start: - 返回第一条记录在完整找到结果中的偏移位置,0开始,一般分页用。
rows: - 指定返回结果最多有多少条记录,配合start来实现分页。
sort: - 排序,格式:sort=+[,+]… 。示例:(score desc, price asc)表示先 "score" 降序, 再 "price" 升序,默认是相关性降序。
wt: - (writer type)指定输出格式,可以有 xml, json, php, phps。
fl表示索引显示那些field( *表示所有field,如果想查询指定字段用逗号或空格隔开(如:Name,SKU,ShortDescription或Name SKU ShortDescription【注:字段是严格区分大小写的】))
q.op 表示q 中 查询语句的 各条件的逻辑操作 AND(与) OR(或)
hl 是否高亮 ,如hl=true
hl.fl 高亮field ,hl.fl=Name,SKU
hl.snippets :默认是1,这里设置为3个片段
hl.simple.pre 高亮前面的格式
hl.simple.post 高亮后面的格式
facet 是否启动统计
facet.field 统计field
-------注:以上是比较常用的参数,当然具体的参数使用还是多看Solr官方的技术文档
---查询文档并以csv保存 测试代码可以执行生成csv文件----
curl http://localhost:8983/solr/tags/query -d 'q=*:*&start=500&rows=300&sort=id asc&wt=csv' | sed '1d' >> tags.csv
curl -s http://localhost:8983/solr/tags/query -d 'q=id:2001394&rows=0'