You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2021/01/05 20:54:09 UTC

[GitHub] [lucene-solr] dsmiley opened a new pull request #2181: SOLR-15069 child parent filter

dsmiley opened a new pull request #2181:
URL: https://github.com/apache/lucene-solr/pull/2181


   https://issues.apache.org/jira/browse/SOLR-15069
   Repeated issue description:
   The `parentFilter` param to `[child]` was once required, and then made only optional if you have a `_nest_path_` field, but I think it can be optional (perhaps obsolete) altogether.  All we have to do is grab the uniqueKey field from the document to be transformed, look this up in the `_root_` field, and you'll get the internal Lucene docId of the first child doc.  No problem, and quick.
   
   CC @moshebla  @thomaswoeckinger
   
   I came about doing this because I too-soon documented in #2159 that `_nest_path_` field was no longer required for doing atomic/partial updates in a nested schema.  Instead of removing the documentation I wrote, and then realizing I would then need to add safety prevention (otherwise child docs could vanish on updates!)... it occurred to me, lets just make it work :-)
   


----------------------------------------------------------------
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.

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-solr] muse-dev[bot] commented on a change in pull request #2181: SOLR-15069 child parent filter

Posted by GitBox <gi...@apache.org>.
muse-dev[bot] commented on a change in pull request #2181:
URL: https://github.com/apache/lucene-solr/pull/2181#discussion_r552251280



##########
File path: solr/core/src/java/org/apache/solr/response/transform/ChildDocTransformer.java
##########
@@ -76,6 +87,37 @@ public String getName()  {
   @Override
   public boolean needsSolrIndexSearcher() { return true; }
 
+  @Override
+  public String[] getExtraRequestFields() {
+    return extraRequestedFields;
+  }
+
+  private int getPrevRootGivenFilter(LeafReaderContext leafReaderContext, int segRootId) throws IOException {
+    final BitSet segParentsBitSet = parentsFilter.getBitSet(leafReaderContext);
+    if (segParentsBitSet != null) {
+      return segRootId == 0 ? -1 : segParentsBitSet.prevSetBit(segRootId - 1);
+    }
+    throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
+        "Parent filter '" + parentsFilter + "' doesn't match any parent documents");
+  }
+
+  private int getPrevRootGivenId(LeafReaderContext leafReaderContext, int segRootId,
+                                 BytesRef idBytes) throws IOException {
+    final LeafReader reader = leafReaderContext.reader();
+    final Terms terms = reader.terms(IndexSchema.ROOT_FIELD_NAME); // never returns null here
+    final TermsEnum iterator = terms.iterator();
+    if (iterator.seekExact(idBytes)) {
+      PostingsEnum docs = iterator.postings(null, PostingsEnum.NONE);
+      docs = BitsFilteredPostingsEnum.wrap(docs, reader.getLiveDocs());
+      int id = docs.nextDoc();

Review comment:
       *NULL_DEREFERENCE:*  object `docs` last assigned on line 111 could be null and is dereferenced at line 112.




----------------------------------------------------------------
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.

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-solr] dsmiley commented on pull request #2181: SOLR-15069 child parent filter

Posted by GitBox <gi...@apache.org>.
dsmiley commented on pull request #2181:
URL: https://github.com/apache/lucene-solr/pull/2181#issuecomment-754916903


   CC @barrotsteindev   (anyone CC'ed or really anyone, I'd appreciate a review)


----------------------------------------------------------------
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.

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-solr] barrotsteindev commented on pull request #2181: SOLR-15069 child parent filter

Posted by GitBox <gi...@apache.org>.
barrotsteindev commented on pull request #2181:
URL: https://github.com/apache/lucene-solr/pull/2181#issuecomment-754920896


   Seems like a great idea.
   I think `parentFilter` still has its place when you want to return a part of a hierarchy where the parent documents are not the root docs(top level parents).
   I guess the `parentFilter` could still be computed using the \_nest_path\_ field, but I guess this is a specialized case and it might be better to let the user supply the `parentFilter` himself.


----------------------------------------------------------------
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.

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-solr] dsmiley merged pull request #2181: SOLR-15069 child parent filter

Posted by GitBox <gi...@apache.org>.
dsmiley merged pull request #2181:
URL: https://github.com/apache/lucene-solr/pull/2181


   


----------------------------------------------------------------
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.

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-solr] dsmiley commented on pull request #2181: SOLR-15069 child parent filter

Posted by GitBox <gi...@apache.org>.
dsmiley commented on pull request #2181:
URL: https://github.com/apache/lucene-solr/pull/2181#issuecomment-754932185


   I was thinking that maybe but I **suspect** (just a theory) the current code "just works" because it tracks the path information already and builds the tree.  It'd just be a sub-tree with docs that don't connect, and I think they would just be dropped/ignored.  It'd be nice to have a test for this to find out for sure.  Even if it does work, it could be better optimized for this case.


----------------------------------------------------------------
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.

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