转载地址:https://blog.csdn.net/wzy18210825916/article/details/80946454
managed-schema.xml中增加ik分词器(或 5版本之前的是 schema.xml )
<!-- 添加IK分词 -->
<fieldType name="text_ik" class="solr.TextField">
<analyzer type="index" isMaxWordLength="false" class="org.wltea.analyzer.lucene.IKAnalyzer"/>
<analyzer type="query" isMaxWordLength="true" class="org.wltea.analyzer.lucene.IKAnalyzer"/>
</fieldType>
catalina.bat中配置日志:
set JAVA_OPTS="-Dsolr.log.dir=d:/solr-7.4.0/solr_home/logs"
solr7.4 配置ikanalyzer和自带的中文分词器
https://blog.csdn.net/guyan0319/article/details/81188977
Solr7.4.0应用部署Demo,比较全面完整:
https://blog.csdn.net/h0713/article/details/82503848
Solr7.4.0的API(Solrj)操作
https://www.cnblogs.com/frankdeng/p/9615856.html
全量:
http://192.168.20.99:8080/solr/wjs_core/dataimport?command=full-import&clean=true&commit=true
增量:
http://192.168.20.99:8080/solr/wjs_core/dataimport?command=delta-import&clean=false&commit=true
solr7.4定时任务增量或全量同步数据: https://developer.aliyun.com/article/660563
注意:deltaQuery="select T_ID from SW_MH_TRAVELNOTE where T_CREATETIME > ‘${dih.last_index_time}’ " 该T_CREATETIME 类型必须是时间戳timestamp,日期都不行 datetime,date
真是一个大坑。
<entity name="travelNoteData" pk="T_ID" transformer="DateFormatTransformer"
query="SELECT T_ID,T_TITLE,T_CONTENT,5 as s_type FROM SW_MH_TRAVELNOTE where T_STATE = 1 ORDER BY T_CREATETIME DESC"
deltaQuery="select T_ID from SW_MH_TRAVELNOTE where T_ID > 50 "
deletedPkQuery="select T_ID from SW_MH_TRAVELNOTE where T_STATE <> 1"
deltaImportQuery="select T_ID,T_TITLE,T_CONTENT,5 as s_type from SW_MH_TRAVELNOTE where T_ID = '${dih.delta.T_ID}'" >
<field column='T_ID' name='id' />
<field column='T_TITLE' name='name' />
<field column='T_CONTENT' name='content' />
<field column='s_type' name='type' />
</entity>
solr7.4版本的定时任务jar要放在tomcat的lib下面 solr-dataimportscheduler-1.1.0.jar
SolrException: Index locked 和 Error opening new searcher 最终解决方案(找了好久才解决)
{msg=SolrCore 'collection1' is not available due to init failure: Error opening new searcher,trace=org.apache.solr.common.SolrException: SolrCore 'collection1' is not available due to init failure: Error opening new searcher at org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:745) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:307) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:207) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:688) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:609) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:818) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1623) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source) Caused by: org.apache.solr.common.SolrException: Error opening new searcher at org.apache.solr.core.SolrCore.<init>(SolrCore.java:881) at org.apache.solr.core.SolrCore.<init>(SolrCore.java:654) at
二、解决方法
以上错误研究了很长时间,网上百度goole了很多解决方法,又是重启tomcat又是重新建立solr配置都无效,无意中用以下方法终于解决了。
只需要在solrconfig.xml中配置 true这个就可以。
1、首先,删除/data/index/write.lock文件,
2、然后,登录 Apache Tomcat 管理界面,点击进入Manager App ,在Applications列表中找到solr站点,点击Reload按钮
Solr7.4 如果修改过solr服务中的文件时,再次启动要删除掉write.lock文件