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