@Indexed
public class Tasks {
@DocumentId
private Long id;
@Field
private String title;
@IndexedEmbedded
private List<Attributes> attributes;
@IndexedEmbedded
private List<Contents> contents;
....
}
@Indexed
public class Attributes {
@DocumentId
private Long id;
@Field
private String name;
@Field
private String value;
@IndexedEmbedded
private Tasks task;
....
}
@Indexed
public class Contents {
@DocumentId
private Long id;
@Field
private String content;
@IndexedEmbedded
private Tasks task;
....
}
Although it looks as if Tasks where at the top of hierarchy, it's mandatory in my project to query all 3 objects, thus all must be indexed. Besides that, query like that:
+title:java +content:java
should return appropriate Tasks and Contents objects
but
+contents:java
is supposed to return only Contents objects (which is not in my case since due to @IndexedEmbedded query will hit associated Tasks as well).
Although i could restrict my search like that: fullTextSession.createFullTextQuery( luceneQuery, Contents.class ) ,
i need to allow searching all indexed objects.
Another workaround that occuried to me might be checking where query's fields belong to and then restricting to that classes in
'createFullTextQuery' but that sounds quite rough to me.
|