Elasticsearch: OneToMany and ManyToOne not included in index


(David-3) #1

I have three play models which I want to index using elastic search.
The first model - model1 - includes a List of type model2 with the
following JPA mapping:
@OneToMany(cascade = {CascadeType.ALL})

The second model includes a member variable of type model3 and the
following JPA settings:
@ManyToOne(fetch=FetchType.EAGER,optional=false)

The third model includes a List of type model2 with JPA following
settings:
@OneToMany(mappedBy="category", cascade = {CascadeType.ALL})

So it looks like this:

public class model1 extends Model{
@OneToMany(cascade = {CascadeType.ALL})
public List m2 = new ArrayList();
}
public class model2 extends Model{
@ManyToOne(fetch=FetchType.EAGER,optional=false)
public model3 m3;
}
public class model3 extends Model{
@OneToMany(mappedBy="m3", cascade = {CascadeType.ALL})
public List m2s;
}

I am indexing existing data from a database by
retrieving a list of JPA models for model1
iterating over them and calling save.
model1 and model2 are indexed successfully but the m2s member variable
in model3 does not appear to be indexed properly. In the mashup UI (es-
admin) the m2s field is listed but when I enter data nothing is
displayed.


(David-3) #2

Does elasticsearch index the data of all objects referenced by the
object you call save on?
I am new to elastic search so maybe there is a better approach to
indexing linked data which I am missing.

I saw this post here which makes me think it does not but it is not
the exact same scenario.
http://groups.google.com/group/elasticsearch/browse_thread/thread/e61ffcb0421eb654/a7cf026802d102ee?lnk=gst&q=JOINS#a7cf026802d102ee

I think if it does not it will be a big reason for me not to use
elasticsearch unless there is a workaround.

On Jun 8, 2:28 pm, David davidrock...@gmail.com wrote:

I have three play models which I want to index using elastic search.
The first model - model1 - includes a List of type model2 with the
following JPA mapping:
@OneToMany(cascade = {CascadeType.ALL})

The second model includes a member variable of type model3 and the
following JPA settings:
@ManyToOne(fetch=FetchType.EAGER,optional=false)

The third model includes a List of type model2 with JPA following
settings:
@OneToMany(mappedBy="category", cascade = {CascadeType.ALL})

So it looks like this:

public class model1 extends Model{
@OneToMany(cascade = {CascadeType.ALL})
public List m2 = new ArrayList();}

public class model2 extends Model{
@ManyToOne(fetch=FetchType.EAGER,optional=false)
public model3 m3;}

public class model3 extends Model{
@OneToMany(mappedBy="m3", cascade = {CascadeType.ALL})
public List m2s;

}

I am indexing existing data from a database by
retrieving a list of JPA models for model1
iterating over them and calling save.
model1 and model2 are indexed successfully but the m2s member variable
in model3 does not appear to be indexed properly. In the mashup UI (es-
admin) the m2s field is listed but when I enter data nothing is
displayed.


(system) #3