You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "lude1994 (via GitHub)" <gi...@apache.org> on 2023/02/13 08:25:39 UTC
[GitHub] [lucene] lude1994 opened a new issue, #12144: ToParentBlockJoinQuery work error
lude1994 opened a new issue, #12144:
URL: https://github.com/apache/lucene/issues/12144
### Description
` final Directory dir = newDirectory();
final IndexWriterConfig config = new IndexWriterConfig(new MockAnalyzer(random()));
config.setMergePolicy(NoMergePolicy.INSTANCE);
// we don't want to merge - since we rely on certain segment setup
final IndexWriter w = new IndexWriter(dir, config);
final List<Document> docs = new ArrayList<>();
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);
docs.clear();
docs.add(makeJob("ruby", 2005));
docs.add(makeJob("java", 2099));
docs.add(makeResume("Lisa", "United States"));
w.addDocuments(docs);
w.commit();
IndexReader r = DirectoryReader.open(w);
w.close();
IndexSearcher s = newSearcher(r);
BitSetProducer parentsFilter =
new QueryBitSetProducer(new TermQuery(new Term("name", "Lisa")));
CheckJoinIndex.check(r, parentsFilter);
BooleanQuery.Builder childQuery = new BooleanQuery.Builder();
childQuery.add(new BooleanClause(new TermQuery(new Term("skill", "java")), Occur.MUST));
childQuery.add(new BooleanClause(IntPoint.newRangeQuery("year", 2006, 2011), Occur.MUST));
ToParentBlockJoinQuery childJoinQuery =
new ToParentBlockJoinQuery(childQuery.build(), parentsFilter, ScoreMode.Avg);
BooleanQuery.Builder fullQuery = new BooleanQuery.Builder();
fullQuery.add(new BooleanClause(childJoinQuery, Occur.MUST));
fullQuery.add(new BooleanClause(new MatchAllDocsQuery(), Occur.MUST));
TopDocs topDocs = s.search(fullQuery.build(), 2);`
In my opinion , the code will return one document (the 3th document ), But actually return two document (the 3th and the 9th document) .so i see the source code , in class ToParentBlockJoinQuery.ParentApproximation.advance() method,
` public int advance(int target) throws IOException {
if (target >= parentBits.length()) {
return doc = NO_MORE_DOCS;
}
final int firstChildTarget = target == 0 ? 0 : parentBits.prevSetBit(target - 1) + 1;
int childDoc = childApproximation.docID();
if (childDoc < firstChildTarget) {
childDoc = childApproximation.advance(firstChildTarget);
}
if (childDoc >= parentBits.length() - 1) {
return doc = NO_MORE_DOCS;
}
return doc = parentBits.nextSetBit(childDoc + 1);
}`
the parentBits is 0000 ... 100000100
child query match 3th and 5th document , when advance 5th document , this code will consider the 9th document as the parent document of the 5th document, and return the 9th document
is this a bug ? or my question .
### Version and environment details
lucene branch_9_0
window 10
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] mkhludnev closed issue #12144: ToParentBlockJoinQuery work error
Posted by "mkhludnev (via GitHub)" <gi...@apache.org>.
mkhludnev closed issue #12144: ToParentBlockJoinQuery work error
URL: https://github.com/apache/lucene/issues/12144
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] lude1994 commented on issue #12144: ToParentBlockJoinQuery work error
Posted by "lude1994 (via GitHub)" <gi...@apache.org>.
lude1994 commented on issue #12144:
URL: https://github.com/apache/lucene/issues/12144#issuecomment-1427583319
> Hi, The parents filter should select _all_ parents as its' stated in javadoc. Not the particular one. You can check [more examples and explanation](https://solr.apache.org/guide/8_2/other-parsers.html#block-join-parent-query-parser) in Solr Ref guide
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] mkhludnev commented on issue #12144: ToParentBlockJoinQuery work error
Posted by "mkhludnev (via GitHub)" <gi...@apache.org>.
mkhludnev commented on issue #12144:
URL: https://github.com/apache/lucene/issues/12144#issuecomment-1427545469
Hi,
The parents filter should select _all_ parents as its' stated in javadoc. Not the particular one. You can check [more examples and explanation](https://solr.apache.org/guide/8_2/other-parsers.html#block-join-parent-query-parser) in Solr Ref guide
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] lude1994 commented on issue #12144: ToParentBlockJoinQuery work error
Posted by "lude1994 (via GitHub)" <gi...@apache.org>.
lude1994 commented on issue #12144:
URL: https://github.com/apache/lucene/issues/12144#issuecomment-1427583820
ok,I now it . thanks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org