【发布时间】:2016-08-06 12:37:01
【问题描述】:
我收到了这个错误:
org.springframework.data.elasticsearch.ElasticsearchException:失败 索引文档 [id: 1]
在 org.springframework.data.elasticsearch.core.ElasticsearchTemplate.prepareIndex(ElasticsearchTemplate.java:1028) 在 org.springframework.data.elasticsearch.core.ElasticsearchTemplate.index(ElasticsearchTemplate.java:525) ...
每次我在我的实体Book 类中放入一个getIndexQuery 方法。所以它看起来像这样:
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Document(indexName = "bookshop", type = "book", shards = 1, replicas = 0, refreshInterval = "-1")
public class Book {
@Id
private String bookId;
@Field(type = FieldType.String, store = true)
private String title;
public IndexQuery getIndexQuery(){
return new IndexQueryBuilder().withId(this.getBookId()).withObject(this).build();
}
}
即使我在代码中没有使用此方法,也会发生错误。 我怎样才能把这个方法放在我的实体类中而不弄乱实体模式(因为这是我假设的问题)?
【问题讨论】:
标签: java spring spring-data