Hello,
I would like to use the ToParentBlockJoinQuery and its collector to
query a document with children and grand children, but I can't figure
out how to get the document ids that represent grand children.
I know how to build the query and get the parent and child documents:
/****Example code start*****/
Query grandChildQuery=new TermQuery(new Term("color", "red"));
Filter childFilter = new CachingWrapperFilter(new RawTermFilter(new
Term("type","child")), DeletesMode.IGNORE);
ToParentBlockJoinQuery grandchildJoinQuery = new
ToParentBlockJoinQuery(grandChildQuery, childFilter, ScoreMode.Max);
BooleanQuery childQuery= new BooleanQuery();
childQuery.add(grandchildJoinQuery, Occur.MUST);
childQuery.add(new TermQuery(new Term("shape", "round")), Occur.MUST);
Filter parentFilter = new CachingWrapperFilter(new RawTermFilter(new
Term("type","parent")), DeletesMode.IGNORE);
ToParentBlockJoinQuery childJoinQuery = new
ToParentBlockJoinQuery(childQuery, parentFilter, ScoreMode.Max);
parentQuery=new BooleanQuery();
parentQuery.add(childJoinQuery, Occur.MUST);
parentQuery.add(new TermQuery(new Term("name", "test")), Occur.MUST);
ToParentBlockJoinCollector parentCollector= new
ToParentBlockJoinCollector(Sort.RELEVANCE, 30, true, true);
searcher.search(parentQuery, null, parentCollector);
TopGroups<Integer> topGroups =
parentCollector.getTopGroups(childJoinQuery, null, 0, 20, 0, false);
/****Example code end*****/
Now topGroups contains the parents document ids, and the child document
ids. But how can I get the grandchild document ids for a given child
document id? Do I have to call
TopGroups<Integer> childTopGroups =
parentCollector.getTopGroups(grandchildJoinQuery , null, 0, 20, 0, false);
and match the document ids by hand? If so, is there a guarantee that
they will be in the same order as I get them in the topgroups, or will I
have to iterate over all childTopGroups until I find the right document id?
Does anyone have example code for nested joins?
Thanks in advance,
Christoph
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org