Github user dsmiley commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/385#discussion_r192117086
  
    --- Diff: solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java 
---
    @@ -175,69 +172,83 @@ public String getHashableId() {
         return id;
       }
     
    -  public boolean isBlock() {
    -    return solrDoc.hasChildDocuments();
    +  /**
    +   * @return String id to hash
    +   */
    +  public String getHashableId() {
    +    return getHashableId(solrDoc);
       }
     
    -  @Override
    -  public Iterator<Document> iterator() {
    -    return new Iterator<Document>() {
    -      Iterator<SolrInputDocument> iter;
    -
    -      {
    -        List<SolrInputDocument> all = flatten(solrDoc);
    -
    -        String idField = getHashableId();
    -
    -        boolean isVersion = version != 0;
    -
    -        for (SolrInputDocument sdoc : all) {
    -          sdoc.setField(IndexSchema.ROOT_FIELD_NAME, idField);
    -          if(isVersion) sdoc.setField(CommonParams.VERSION_FIELD, version);
    -          // TODO: if possible concurrent modification exception (if 
SolrInputDocument not cloned and is being forwarded to replicas)
    -          // then we could add this field to the generated lucene document 
instead.
    -        }
    -
    -        iter = all.iterator();
    -     }
    +  public List<SolrInputDocument> computeFlattenedDocs() {
    +    List<SolrInputDocument> all = flatten(solrDoc);
     
    -      @Override
    -      public boolean hasNext() {
    -        return iter.hasNext();
    -      }
    +    String rootId = getHashableId();
     
    -      @Override
    -      public Document next() {
    -        return DocumentBuilder.toDocument(iter.next(), req.getSchema());
    -      }
    +    boolean isVersion = version != 0;
     
    -      @Override
    -      public void remove() {
    -        throw new UnsupportedOperationException();
    +    for (SolrInputDocument sdoc : all) {
    +      if (all.size() > 1) {
    --- End diff --
    
    oooooooh, I see now.  I think we should try to clarify this; perhaps it may 
be just a matter of method naming but probably a bit more.  3 cases ought to be 
better distinguished:
    * an in-place update. Will have no children concerns to deal with (no 
\_root_ to set, not \_version\_) to set).  Presence of children here should 
throw an error.
    * a normal add/update of one document (detected via having no children).  
Here we don't set the \_root_ or \_version_
    * a normal add/update of a set of a set of documents part of a tree.
    
    Maybe I'll take a stab at this?


---

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

Reply via email to