- 安裝及使用:
- 下載及壓縮執行:
[shell]wget http://download.nextag.com/apache/lucene/solr/4.2.0/solr-4.2.0.tgz
[com]下載[/com]
[shell]tar -zxvf solr-4.2.0.tgz
[com]解壓縮執行[/com]
[shell]cd solr/example
[shell]java -jar start.jar [tell]執行主程式[/tell]
INFO::Started [email protected]:8983 代表啟動
http://localhost:8983/solr/select?q=*:*&wt=xml
[shell]cd solr/example/exampledocs
[shell]vim test.json
[vim][tell]json格式[/tell]
{
"id" : "1",
"name" : "第1篇文章"
}
,
{
"id" : "2",
"name" : "第2篇文章"
}
][/vim]
[shell]cd solr/example/exampledocs
[shell]vim test.xml
[vim][tell]XML格式[/tell]
<add>
<doc>
<field name="id">1</field>
<field name="name">第1篇文章內容</field>
</doc>
<doc>
<field name="id">2</field>
<field name="name">第2篇文章內容</field>
</doc>[/vim]
[shell]cd solr/example/exampledocs
[shell]./post.sh test.xml
[shell]cd solr/example/exampledocs
[shell]cp post.sh post_json.sh
[shell]vim post_json.sh
[vim]curl $URL --data-binary @$f -H 'Content-type:application/json'
[com] 第22行,xml 改成 json[/com][/vim]
q - 查詢字串,必須的。
fq - 在q查詢符合結果中同時是fq查詢符合的。
fl - 指定返回那些欄位內容,用逗號或空格分隔多個。
start - 返回第一條記錄在完整找到結果中的偏移位置,0開始,一般分頁用。
rows - 指定返回結果最多有多少條記錄,配合start來實現分頁。
sort - 排序,格式:sort=
wt - (writer type)指定輸出格式,可以有 xml, json, php, phps,
q.op - 覆蓋 schema.xml 的 defaultOperator
df - 默認的查詢欄位,一般默認指定
qt - (query type)指定那個類型來處理查詢請求,一般不用指定,默認是standard。
indent - true|on, json, php, phps, ruby輸出才有必要用這個參數。