本人下载了solr-4.10.4版本,下载解压后打开example目录,内有示例程序,参照其README.txt可以直接实用jetty运行,用工具导入数据。
运行,打开命令窗口,在该目录下执行:java -jar start.jar
示例数据在exampledocs目录下,进入该目录,执行:java -jar post.jar *.xml
即可完成导入数据,详细参考自带文档。
如果需要在Tomcat运行,首先,拷贝出webapps内solr.war到Tomcat应用目录,这里实用了Tomcat7版本。
需要注意的是,首先是配置Solr的Home目录,打开web.xml文件:
官方默认注释掉了该部分,打开,修改为:
solr/home
D:\tomcat\solr-4.10.4\example\solr
java.lang.String
这里实用的就是Solr自带的Home目录,这个目录可以更换位置。
再者,在Tomcat行跑,需要增加两个Jar包:
commons-logging-1.2.jar
slf4j-api-1.7.6.jar
否则会报错:严重: Exception starting filter SolrRequestFilter
java.lang.NoClassDefFoundError: Failed to initialize Apache Solr: Could not find necessary SLF4j logging jars.
If using Jetty, the SLF4j logging jars need to go in the jetty lib/ext directory. For other containers,
the corresponding directory should be used. For more information, see: http://wiki.apache.org/solr/SolrLogging
at org.apache.solr.servlet.CheckLoggingConfiguration.check(CheckLoggingConfiguration.java:28)
at org.apache.solr.servlet.BaseSolrFilter.(BaseSolrFilter.java:31)
和三月 11, 2016 2:28:42 下午 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter SolrRequestFilter
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.apache.http.impl.client.CloseableHttpClient.(CloseableHttpClient.java:60)
at org.apache.http.impl.client.AbstractHttpClient.(AbstractHttpClient.java:271)
at org.apache.http.impl.client.DefaultHttpClient.(DefaultHttpClient.java:127)
这种问题不多解释。
如下图所示,安装成功。
结束