Hello Mike,
thank you for your response. Unfortunately, I won't be able to try this
today, but I should be able to try it in the next few days. If I find
the bug you described, I will open an issue.
On a somewhat related note, is there a way to get the scores for the
parent documents from the ToParentBlockJoinCollector? I can tell the
collector to track the scores and the max score, but I did not find a
way to retrieve either the parent scores nor the max score (of the
parent documents).
Christoph Kaser
Am 23.05.2012 20:10, schrieb Michael McCandless:
You do have to call getTopGroups for each grandchild query, and the
order should match the TopGroups you got for the children
However .... looking at the code, I suspect there's a bug... by the
time the collector collects the parent hit, some of the grand children
will have been discarded. I suspect you'll only get back
grandchildren for the last child docID under each parent docID's
group. Are you seeing that?
Tricky... can you open an issue?
Mike McCandless
http://blog.mikemccandless.com
On Wed, May 23, 2012 at 12:22 PM, Christoph Kaser
<lucene_l...@iconparc.de> wrote:
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