1、先下载Apache Solr
1.3 https://www.docsj.com/doc/286183169.html,/lucene/solr/1.3.0/apache-solr-1.3.0.zip,解压到如E:\apache-solr-1.3.0。
2、下载Apache Tomcat
6.0.18 https://www.docsj.com/doc/286183169.html,/apache-mirror/tomcat/tomcat-6/v6.0.18/bin/a pache-tomcat-6.0.18.zip,解压到如E:\apache-tomcat-6.0.18。
3、solr 安装到tomcat。修改E:\apache-tomcat-6.0.18\conf\server.xml,加个URIEncoding="UTF-8",把8080 的那一块改为:
1. 2.connectionTimeout="20000" 3.redirectPort="8443"URIEncoding="UTF-8"/> 把下面的内容保存到E:\apache-tomcat-6.0.18\conf\Catalina\localhost\solr.xml,没有这个目录自行创建。 1. e="true"> 2. 3. solr 的更多方式请看:solr install 4、现在安装好,启动tomcat,并打开http://localhost:8080/solr/admin/看看界面。 5、为搜索论坛帖子应用设计索引结构: 6、上面的索引结构告诉solr,把下面的内容覆盖 E:\apache-solr-1.3.0\example\solr\conf\scheam.xml,(可以先备份这文件,方便以后看官方示例): 1. 2. 3. 4. 5. 6. itNorms="true"/> 7. 8. 9. 29. tNorms="true"/> 30. 31. > 32. 33. 34. 35. 36. 37. 38. 39. 40. /> 41. 42. 43. 44. "NOW"/> 45. 46. 48. "true"/> 49. 50. 51. 54. 55. 56. 57. 58. 59. 60. 61. 62. 65. 66. 67. 68. 69. 7、重启tomcat,然后手动在E:\apache-solr-1.3.0\example\exampledocs 创建两个xml 数据文件。分别保存为demo-doc1.xml 和demo-doc2.xml: 1. 2. 3. 4. 5. 6. 7. 如:服务器,可以试查找它。 8. 9. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 8、提交数据做索引,到E:\apache-solr-1.3.0\example\exampledocs,运行: E:\apache-solr-1.3.0\example\exampledocs>java -Durl=http://localhost:8080/solr/update -Dcommit=yes -jar post.jar demo-doc*.xml SimplePostTool: version 1.2 SimplePostTool: WARNING: Make sure your XML documents are encoded in UTF-8, other encodings are not currently supported SimplePostTool: POSTing files to http://localhost:8080/solr/update.. SimplePostTool: POSTing file demo-doc1.xml SimplePostTool: POSTing file demo-doc2.xml SimplePostTool: COMMITting Solr index changes.. 9、查看搜索结果: 所有内 容http://localhost:8080/solr/select/?q=*%3A*&version=2.2&start=0&rows= 10&indent=on 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 器,可以试查找它。 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. bory.chan 用户的: http://localhost:8080/solr/select/?q=user%3Abory.chan&version=2.2&start= 0&rows=10&indent=on 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 时 间http://localhost:8080/solr/select/?q=timestamp%3A%5B%222009-02-18T 00%3A00%3A00Z%22+TO+%222009-02-19T00%3A00%3A00Z%22%5D&v ersion=2.2&start=0&rows=10&indent=on 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 常用的solr 查询参数请看:solr 查询参数说明 简单的示例已经完成了,索引文件(默认)会在CWD/solr/data/index 目录下,要改为solr.home/data目录下,在 F:\apache-solr-1.3.0\example\solr\conf\solrconfig.xml 把dataDir 注释掉,如: 1.