我有一个应用程序,其中MongoDB用作主数据存储,Elasticsearch用于所有搜索。现在我不确定如何正确映射,因为在使用MongoDB和Elasticsearch @Document注释注释模型类时(如下例所示)我得到的错误如下。
引起:org.springframework.data.mapping.PropertyReferenceException:找不到类型为Customer的属性插入!
// my model definition excerpt
@org.springframework.data.mongodb.core.mapping.Document(collection="companies")
@org.springframework.data.elasticsearch.annotations.Document(indexName = "netnotes", type = "company")
public class Customer implements Serializable{
....
}
我的问题与How to modeling when use Spring data mongo and Spring data elasticearch?相同,但没有答案......
答案 0 :(得分:0)
我有同样的问题,经过一些阅读后发现Spring JPA捆绑了工厂存储库,所以你有一个弹性存储库试图解析你的mongo实体。
您基本上必须将存储库放在单独的包中,以防止在您的mongo或弹性配置存储库扫描中发生冲突。
对我而言,我只需要将我的弹性搜索配置隔离开来,让它保持原状。
请参阅以下链接中说明的解决方案。