[ 
https://issues.apache.org/jira/browse/LUCENE-5409?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13880597#comment-13880597
 ] 

Peng Cheng edited comment on LUCENE-5409 at 1/24/14 1:24 AM:
-------------------------------------------------------------

Still doesn't work, this is my test case, perhaps I still need to implement a 
Query with custom rewrite and hashcode

  public void testRewriteHash() throws IOException
  {
    final Directory dir = newDirectory();
    final RandomIndexWriter w = new RandomIndexWriter(random(), dir);

    final List<Document> docs = new ArrayList<Document>();

    docs.add(makeJob("java", 2007));
    docs.add(makeJob("python", 2010));
    docs.add(makeResume("Lisa", "United Kingdom"));
    w.addDocuments(docs);

    docs.clear();
    docs.add(makeJob("ruby", 2005));
    docs.add(makeJob("java", 2006));
    docs.add(makeResume("Frank", "United States"));
    w.addDocuments(docs);

    IndexReader r = w.getReader();
    w.close();
    IndexSearcher s = newSearcher(r);

    Query q = new TermQuery(new Term("skill","rudy"));
    BooleanQuery qc = new BooleanQuery();
    qc.add(q,Occur.SHOULD);
    Filter parentsFilter = new FixedBitSetCachingWrapperFilter(new 
QueryWrapperFilter(new TermQuery(new Term("docType", "resume"))));

    Query qp = new ToParentBlockJoinQuery(qc,parentsFilter,ScoreMode.Max);
    int hash1 = qp.hashCode();
    Query qw = s.rewrite(qp);
    int hash2 = qp.hashCode();

    assertTrue(hash1 != hash2);
  }


was (Author: peng):
Still doesn't work, this is my test case:

  public void testRewriteHash() throws IOException
  {
    final Directory dir = newDirectory();
    final RandomIndexWriter w = new RandomIndexWriter(random(), dir);

    final List<Document> docs = new ArrayList<Document>();

    docs.add(makeJob("java", 2007));
    docs.add(makeJob("python", 2010));
    docs.add(makeResume("Lisa", "United Kingdom"));
    w.addDocuments(docs);

    docs.clear();
    docs.add(makeJob("ruby", 2005));
    docs.add(makeJob("java", 2006));
    docs.add(makeResume("Frank", "United States"));
    w.addDocuments(docs);

    IndexReader r = w.getReader();
    w.close();
    IndexSearcher s = newSearcher(r);

    Query q = new TermQuery(new Term("skill","rudy"));
    BooleanQuery qc = new BooleanQuery();
    qc.add(q,Occur.SHOULD);
    Filter parentsFilter = new FixedBitSetCachingWrapperFilter(new 
QueryWrapperFilter(new TermQuery(new Term("docType", "resume"))));

    Query qp = new ToParentBlockJoinQuery(qc,parentsFilter,ScoreMode.Max);
    int hash1 = qp.hashCode();
    Query qw = s.rewrite(qp);
    int hash2 = qp.hashCode();

    assertTrue(hash1 != hash2);
  }

> ToParentBlockJoinCollector.getTopGroups returns empty Groups
> ------------------------------------------------------------
>
>                 Key: LUCENE-5409
>                 URL: https://issues.apache.org/jira/browse/LUCENE-5409
>             Project: Lucene - Core
>          Issue Type: Bug
>          Components: core/search
>    Affects Versions: 4.6
>         Environment: Ubuntu 12.04
>            Reporter: Peng Cheng
>            Assignee: Michael McCandless
>            Priority: Critical
>             Fix For: 4.7
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> A bug is observed to cause unstable results returned by the getTopGroups 
> function of class ToParentBlockJoinCollector.
> In the scorer generation stage, the ToParentBlockJoinCollector will 
> automatically rewrite all the associated ToParentBlockJoinQuery (and their 
> subqueries), and save them into its in-memory Look-up table, namely 
> joinQueryID (see enroll() method for detail). Unfortunately, in the 
> getTopGroups method, the new ToParentBlockJoinQuery parameter is not 
> rewritten (at least users are not expected to do so). When the new one is 
> searched in the old lookup table (considering the impact of rewrite() on 
> hashCode()), the lookup will largely fail and eventually end up with a 
> topGroup collection consisting of only empty groups (their hitCounts are 
> guaranteed to be zero).
> An easy fix would be to rewrite the original BlockJoinQuery before invoking 
> getTopGroups method. However, the computational cost of this is not optimal. 
> A better but slightly more complex solution would be to save unrewrited 
> Queries into the lookup table.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to