Json格式对solr索引进行更新
solr3.1开始支持json格式的索引更新首先需要修改solrconfig.xml添加Json的requestHandler
<requestHandler name="/update/json" class="solr.JsonUpdateRequestHandler"/>
Example
在example/exampledocs/books.json里有json的样本供我们测试
用HTTP-POST的方式索引json格式数据的例子:
cd example/exampledocs
curl 'http://localhost:8983/solr/update/json?commit=true' --data-binary @books.json -H 'Content-type:application/json'
参数中带上了commit=true,提交的内容是可以立刻被查询的了
查询例子:
http://localhost:8983/solr/select?q=name:Lucene&wt=json&indent=true
返回:
{
"responseHeader":{
"status":0,
"QTime":4,
"params":{
"indent":"true",
"q":"name:Lucene",
"wt":"json"}},
"response":{"numFound":1,"start":0,"docs":[
{
"id":"978-1933988177",
"name":"Lucene in Action, Second Edition",
"author":"Michael McCandless",
"sequence_i":1,
"genre_s":"IT",
"inStock":true,
"price":30.5,
"pages_i":475,
"cat":["book","paperback"]}]
}}
页:
[1]