这里忽略java安装和tomcat安装,这里使用的是solr-4.10.0html
一、到apache下载solr,地址:java
http://mirrors.hust.edu.cn/apache/lucene/solr/web
二、解压出solr-4.10.0apache
三、复制solr-4.10.0\example\webapps中的solr.war文件到tomcat安装目录中的webapps文件夹下json
四、运行tomcat。(忽略怎么运行tomcat),tomcat会自动解压solr.war文件。tomcat
五、删除solr.war文件。(否则每次启动tomcat都会发布一次)app
六、回到tomcat的webapps目录下,记事本打开solr\WEB-INF\web.xml文件。webapp
加入以下代码:在<web-app />节点内的最后。post
<env-entry> <env-entry-name>solr/home</env-entry-name> <env-entry-value>E:\solrhome</env-entry-value> <env-entry-type>java.lang.String</env-entry-type> </env-entry>
如上代码,须要在E盘新建一个文件夹:solrhome测试
七、回到解压的solr-4.10.0目录,打开文件夹:solr-4.10.0\example\solr,复制全部内容到E:\solrhome
八、打开文件夹:solr-4.10.0\example\lib\ext,复制全部jar包到tomcat的webapps\solr\WEB-INF\lib下。
九、运行web:http://localhost:8899/solr,将看到以下画面:
十、在E:\solrhome目录下,新建一个mycore文件夹。
十一、在解压的solr-4.10.0\example\multicore目录中,复制core0文件夹到E:\solrhome\mycore中。
十二、在E:\solrhome中新建一个文件夹:mydocs
1三、复制解压的solr-4.10.0\example\exampledocs下的post.jar到E:\solrhome\mydocs中
1四、复制解压的solr-4.10.0\example\multicore\exampledocs下的ipod_other.xml文件到E:\solrhome\mydocs中
1五、在solr web page中新建core:
1六、重启tomcat。(如何重启,忽略)
1七、打开CMD,运行下面语句:(怎么在命令行下运行java就不说了)
java -Durl=http://localhost:8899/solr/mycore/update -Ddata=files -jar post.jar ipod_other.xml
1八、在solr web中选择core:
1九、查询测试:
20、也能够直接使用URL查询:
http://localhost:8899/solr/mycore/select?q=name%3AB*&wt=json&indent=true&_=1410949535746
返回JSON:
{ "responseHeader":{ "status":0, "QTime":0}, "response":{"numFound":1,"start":0,"docs":[ { "id":"F8V7067-APL-KIT", "name":"Belkin Mobile Power Cord for iPod w/ Dock", "_version_":1479481822989516800}] }}
摘自:http://www.cnblogs.com/HD/p/3977799.html