继续上篇文章问题:
解决方法可以在solrconfig.xml中进行配置:大概在234行:
<!--
<deletionPolicy class="solr.SolrDeletionPolicy">
-->
<!-- The number of commit points to be kept -->
<!-- <str name="maxCommitsToKeep">1</str> -->
<!-- The number of optimized commit points to be kept -->
<!-- <str name="maxOptimizedCommitsToKeep">0</str> -->
<!--
Delete all commit points once they have reached the given age.
Supports DateMathParser syntax e.g.
-->
<!--
<str name="maxCommitAge">30MINUTES</str>
<str name="maxCommitAge">1DAY</str>
-->
<!--
</deletionPolicy>
-->
可以配置执行时间,根据业务需求,或者索引更新频率,进行执行;
另外,也可以在solrj
optimizesolr.optimize("goods");这个可以加上判断当前时间,进行间隔执行