我使用Spring starter Data - Solr,并希望使用Spring的分离支持,如文档中所述。
每当刷新应用程序上下文时,自动架构填充将检查域类型,并根据属性配置将新字段填充到索引中。这需要solr在Schemaless模式下运行。
然而,我无法做到这一点。据我所见,Spring不启用@EnableSolrRepositories注释中的schemaCreationSupport标志。所以我尝试了以下几点:
@SpringBootApplication
@EnableSolrRepositories(schemaCreationSupport = true)
public class MyApplication {
@Bean
public SolrOperations solrTemplate(SolrClient solr) {
return new SolrTemplate(solr);
}
}但是在Wireshark中,当通过存储库保存新实体时,我看不到对Schema的任何调用。
这是为了工作,还是我错过了什么?我使用Solr 6.2.0和Spring 1.4.1。
发布于 2016-10-12 14:00:37
我也遇到过同样的问题。经过一些调试之后,我发现了模式创建(或更新)根本没有发生的根本原因:
通过使用@EnableSolrRepositories注释,Spring扩展将向上下文中添加一个工厂bean,从而创建存储库中使用的SolrTemplate。该模板初始化一个SolrPersistentEntitySchemaCreator,应该执行创建/更新。
public void afterPropertiesSet() {
if (this.mappingContext == null) {
this.mappingContext = new SimpleSolrMappingContext(
new SolrPersistentEntitySchemaCreator(this.solrClientFactory)
.enable(this.schemaCreationFeatures));
}
// ...
}问题是,在工厂调用schemaCreationFeatures (启用创建者)标志之后,afterPropertiesSet()被设置为afterPropertiesSet(),因此创建者不可能完成它的工作。
我将在问题跟踪器中创建一个问题。现在不要看到任何解决办法,其他的方法是使用自定义的叉/构建spring-数据,或者扩展一组spring-类,并试图在使用之前通过使用(但怀疑这一点)来设置标志。
https://stackoverflow.com/questions/39791966
复制相似问题