在当前项目中,我正在使用 Elasticsearch Spring Data (3.0.9) 和 ES 5.5.0,并且我正在研究父子关系的使用(更具体地说,我正在测试哪种方法[在性能方面]更好)使用 - 嵌套对象或父子关系]。这是我所得到的
父实体:
@Document(indexName = "testIndex", type="parentItem", createIndex = false)
public class ParentItem {
@Id
private String id;
@Field(type = FieldType.Text)
@JsonProperty("value")
private String value;
// getters and setters
}
Run Code Online (Sandbox Code Playgroud)
子实体:
@Document(indexName = "testIndex", type="childItem", createIndex = false)
public class ChildItem {
@Id
private String id;
@Field(type = FieldType.Keyword, store = true)
@Parent(type = "parentItem")
private String parentId;
@Field(type = FieldType.Text)
@JsonProperty("value")
private String value;
// getters and setters
}
Run Code Online (Sandbox Code Playgroud)
然后 ofc …
java spring elasticsearch spring-data spring-data-elasticsearch