Hi,
I am using Spring Data Elasticsearch 4.0.0 and I would like to establish a parent-child-relationship between my entities. I found out that @JoinTypeRelation
comes with version 4.1.X, but unfortunately, I am stuck with 4.0.0. The official documentation does not have any information about how to implement join-fields, but I hope there is still a way to do it.
In order to give some more detailed information: Since types are no longer supported in ES 7.6.2, I merged my two entities, parent and child, into a single class which holds either parent or child information, but never both.
@Document(indexName = "my_index")
public class ParentOrChild {
@Id
private String _id;
@Field(type = FieldType.Keyword)
private String someParentProperty;
@Field(type = FieldType.Keyword)
private String someChildProperty;
// getters and setters
}
Now I would like to create a join-field so that entities that represent a child can reference another entitiy that represents a parent. My goal is to later find parent entities by searching for properties of their children like this:
GET my_index/_search
{
"query": {
"has_child" : {
"type" : "_doc",
"query" : {
"fuzzy" : {
"someChildProperty" : "value"
}
}
}
}
}
I appreciate any hints you can give me.