You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by "dsmiley (via GitHub)" <gi...@apache.org> on 2026/08/18 04:39:25 UTC

[PR] _nest_path_: allow val to be provided [solr]

dsmiley opened a new pull request, #4748:
URL: https://github.com/apache/solr/pull/4748

   For expert/advanced usage.
   
   


-- 
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@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] _nest_path_: allow val to be provided [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on PR #4748:
URL: https://github.com/apache/solr/pull/4748#issuecomment-5332663542

   Admittedly I shouldn't do 2 things in this PR as the refactoring obscures my primary intent.  But achieving my intent was slightly more complicated without the refactor.  So the refactor can be extracted independently assuming we agree on it.


-- 
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@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] _nest_path_: allow val to be provided [solr]

Posted by "alessandrobenedetti (via GitHub)" <gi...@apache.org>.
alessandrobenedetti commented on code in PR #4748:
URL: https://github.com/apache/solr/pull/4748#discussion_r3861262371


##########
solr/core/src/java/org/apache/solr/update/processor/NestedUpdateProcessorFactory.java:
##########
@@ -78,87 +79,128 @@ private static class NestedUpdateProcessor extends UpdateRequestProcessor {
       this.storePath = storePath;
       this.uniqueKeyFieldName = req.getSchema().getUniqueKeyField().getName();
       this.schema = req.getSchema();
+      this.hasMultiValuedVectorField = hasMultiValuedVectorField(schema);
+    }
+
+    /** Whether any field, explicit or dynamic, could yield vectors to split into nested docs. */
+    private static boolean hasMultiValuedVectorField(IndexSchema schema) {
+      for (SchemaField field : schema.getFields().values()) {
+        if (isMultiValuedVectorField(field)) {
+          return true;
+        }
+      }
+      for (IndexSchema.DynamicField dynamicField : schema.getDynamicFields()) {
+        if (isMultiValuedVectorField(dynamicField.getPrototype())) {
+          return true;
+        }
+      }
+      return false;
+    }
+
+    private static boolean isMultiValuedVectorField(SchemaField sfield) {
+      return sfield.getType() instanceof DenseVectorField && sfield.multiValued();
     }
 
     @Override
     public void processAdd(AddUpdateCommand cmd) throws IOException {
       SolrInputDocument doc = cmd.getSolrInputDocument();
-      processDocChildren(doc, null);
+      final String rootPath = rootPathPrefix(doc);
+      processDocChildren(doc, rootPath);
+      if (hasMultiValuedVectorField) {
+        // after the children; the docs it generates must not be walked as children themselves
+        processMultiValuedVectorFields(doc, rootPath);
+      }

Review Comment:
   Hi David, I agree with the refactor, but It seems the pull request has been closed with no merge, nor I can see a link to new separate pull requests? ideally I would like to see two pull requests, but If you want to do it all in once, I reckon is small enough to do it.
   Let me know!



-- 
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@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] _nest_path_: allow val to be provided [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley commented on code in PR #4748:
URL: https://github.com/apache/solr/pull/4748#discussion_r3801090014


##########
solr/core/src/java/org/apache/solr/update/processor/NestedUpdateProcessorFactory.java:
##########
@@ -78,87 +79,128 @@ private static class NestedUpdateProcessor extends UpdateRequestProcessor {
       this.storePath = storePath;
       this.uniqueKeyFieldName = req.getSchema().getUniqueKeyField().getName();
       this.schema = req.getSchema();
+      this.hasMultiValuedVectorField = hasMultiValuedVectorField(schema);
+    }
+
+    /** Whether any field, explicit or dynamic, could yield vectors to split into nested docs. */
+    private static boolean hasMultiValuedVectorField(IndexSchema schema) {
+      for (SchemaField field : schema.getFields().values()) {
+        if (isMultiValuedVectorField(field)) {
+          return true;
+        }
+      }
+      for (IndexSchema.DynamicField dynamicField : schema.getDynamicFields()) {
+        if (isMultiValuedVectorField(dynamicField.getPrototype())) {
+          return true;
+        }
+      }
+      return false;
+    }
+
+    private static boolean isMultiValuedVectorField(SchemaField sfield) {
+      return sfield.getType() instanceof DenseVectorField && sfield.multiValued();
     }
 
     @Override
     public void processAdd(AddUpdateCommand cmd) throws IOException {
       SolrInputDocument doc = cmd.getSolrInputDocument();
-      processDocChildren(doc, null);
+      final String rootPath = rootPathPrefix(doc);
+      processDocChildren(doc, rootPath);
+      if (hasMultiValuedVectorField) {
+        // after the children; the docs it generates must not be walked as children themselves
+        processMultiValuedVectorFields(doc, rootPath);
+      }

Review Comment:
   @alessandrobenedetti , I see you added multi-valued vector field detection to this class.  You added logic to processDocChildren so that only at the root level, it did it's work.  I found this made processDocChildren much longer and somewhat more complex than if it was a separate pass scoped to this.  So I did that here and I'd like your opinion.  My only concern is that we lookup the SchemaField twice per root doc field instead of once.   Probably a minor concern but still.  I added a boolean hasMultiValuedVectorField to this URP to pre-compute wether it's impossible or not.  
   
   I suppose it'd be handy if SolrInputField was expanded to also include the SchemaField so that _any_ processing relative to the schema by any URP + final Document building does a lookup just once.



-- 
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@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org


Re: [PR] _nest_path_: allow val to be provided [solr]

Posted by "dsmiley (via GitHub)" <gi...@apache.org>.
dsmiley closed pull request #4748: _nest_path_: allow val to be provided
URL: https://github.com/apache/solr/pull/4748


-- 
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@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org