solr依賴java 8 運行環境,因此咱們先安裝java。若是沒有java環境沒法啓動solr服務,而且會看到以下提示:php
[root@localhost solr-6.1.0]# ./bin/solr start -e cloud -noprompt /*運行solr服務*/ Java not found, or an error was encountered when running java. A working Java 8 is required to run Solr! Please install Java 8 or fix JAVA_HOME before running this script. Command that we tried: 'java -version' [root@localhost ~]# java -version /*檢測是否已安裝java*/ [root@localhost ~]# yum install -y java /*安裝java*/
二、下載&安裝&啓動&中止
1.一、下載&安裝:下載安裝包,而後直接解壓到指定目錄便可。
html
[root@localhost ~]# wget http://ftp.meisei-u.ac.jp/mirror/apache/dist/lucene/solr/6.1.0/solr-6.1.0.tgz [root@localhost ~]# tar zxvf solr-6.1.0.tgz -C /usr/local/ [root@localhost ~]# cd /usr/local/solr-6.1.0 [root@localhost solr-6.1.0]# ls bin CHANGES.txt contrib dist docs example licenses LICENSE.txt LUCENE_CHANGES.txt NOTICE.txt README.txt server [root@localhost solr-6.1.0]# ./bin/solr -help /*查看solr命令幫助*/ [root@localhost solr-6.1.0]# ./bin/solr status /*查看solr服務啓動狀態*/
[root@localhost solr-6.1.0]# ./bin/solr start -e cloud -noprompt /*啓動solr服務*/ Welcome to the SolrCloud example! Starting up 2 Solr nodes for your example SolrCloud cluster. /*省略中間部分*/ SolrCloud example running, please visit: http://localhost:8983/solr /*瀏覽器打開這個url能夠看到solr的運行狀況*/ [root@localhost solr-6.1.0]# ps aux | grep solr /*能夠看到solr服務進程*/ [root@localhost solr-6.1.0]# ./bin/solr start -help /*查看啓動命令幫助*/
[root@localhost solr-6.1.0]# ./bin/solr stop -all [root@localhost solr-6.1.0]# ./bin/solr start -help /*查看中止命令幫助*/
[root@localhost solr-6.1.0]# ./bin/post -c gettingstarted filename.json
[root@localhost solr-6.1.0]# ./bin/post -c gettingstarted ~/docdir
[root@localhost solr-6.1.0]# ./bin/post -c gettingstarted http://lucene.apache.org/solr -recursive 1 -delay 1
[root@localhost solr-6.1.0]# echo '{commit: {}}' | ./bin/post -c gettingstarted -type application/json -out yes -d
[root@localhost solr-6.1.0]# ./bin/post -c gettingstarted -type text/csv -out yes -d $'id,value\n1,0.47'
[root@localhost solr-6.1.0]# ./bin/post -c gettingstarted -d "<delete><id>SP2514N</id></delete>"
[root@localhost solr-6.1.0]# curl "http://localhost:8983/solr/gettingstarted/select?q=*:*&wt=json&indent=true"5.二、搜索API經常使用參數說明 5.2.一、參數[q=keyword|field:value|keyword1+keyword2|keyword1+-keyword2]:搜索關鍵字|包含value的字段field|同時包含keyword1和keyword2|包含keyword1,但不包含keyword2。 5.2.二、參數[wt=json]:結果返回格式:json、xml、python、ruby、php、csv等。 5.2.三、參數[start=0]:分頁偏移量,即從第幾條開始。 5.2.四、參數[rows=10]:每頁數量,默認10。 5.2.五、參數[fl=id[,field2,field3,...]]:結果只返回指定的字段,多個用「,」隔開。 5.2.六、參數[indent=false|true]:返回結果個否格式化(縮進)。 5.2.七、參數[fq=field:value]:過濾結果 5.2.八、參數[facet=true|false|on|off]:開始/關閉分組,統計分組數量 5.2.八、參數[facet.field=field]:以field字段分組統計 更多參數說明:https://cwiki.apache.org/confluence/display/solr/Query+Syntax+and+Parsing