solr的项目配置步骤
(1)在F:\fullsearch\solr\apache-tomcat-8.0.52\webapps\solr\WEB-INF中的web.xml 修改指向solrhome路径
<env-entry>
<env-entry-name>solr/home</env-entry-name>
<env-entry-value>F:\fullsearch\solr\solrhome</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
(2)修改数据库配置 在F:\fullsearch\solr\solrhome\collection1\conf的data-config.xml
(3)执行solr.sql脚本
(4)在javaweb项目中的springmvc.xml中配置,类似引用solr服务
<!-- 配置SolrJ -->
<bean id="solrServer" class="org.apache.solr.client.solrj.impl.HttpSolrServer">
<constructor-arg value="http://localhost:8080/solr/collection1"/>
</bean>
(5)启动tomcat下面的solr服务,在启动jabaweb的服务,就可以连接。
(6)在F:\fullsearch\solr\apache-tomcat-8.0.52\webapps\solr\WEB-INF\classes的ext.dic中添加粉刺需要,比如不加这个 金服只能被分为 金 服 ,加了金服2个字,可以分为 金服 金 服
solr添加登录名和密码步骤
在tomcat文件中找到tomcat-users.xml添加
<role rolename="solr"/>
<user username="admin" password="admin" roles="solr"/> //用户名和密码
在solr的web.xml文件中添加
<security-constraint>
<web-resource-collection>
<web-resource-name>Solr Lockdown</web-resource-name>
<url-pattern>/</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<description>This applies only to the "tomcat" security role</description>
<role-name>solr</role-name>
<role-name>admin</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Solr</realm-name>
</login-config>
到这一步访问http://localhost:8080/solr 就会提醒输入密码
在java代码中 applicationContext-solr.xml
<solr:solr-server id ="solrServer" url="http://admin:admin@localhost:8080/solr/collection1"/> //用户名:密码
<bean id="solrTemplate" class="org.springframework.data.solr.core.SolrTemplate">
<constructor-arg ref ="solrServer"/>
</bean>
参考url https://blog.csdn.net/kevon_sun/article/details/80711547