[ 
https://issues.apache.org/jira/browse/SOLR-139?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12470081
 ] 

Ryan McKinley commented on SOLR-139:
------------------------------------

Is this what you are suggesting?

I added a second searcher to DirectUpdatehandler2 that is only closed when you 
call commit();  


  // Check if the document has not been commited yet
  Integer cnt = pset.get( id.toString() );
  if( cnt != null && cnt > 0 ) {
    commit( new CommitUpdateCommand(false) );
  }
  if( committedSearcher == null ) {
    committedSearcher = core.newSearcher("DirectUpdateHandler2.committed");
  }
  Term t = new Term( uniqueKey.getName(), uniqueKey.getType().toInternal( 
id.toString() ) );
  int docID = committedSearcher.getFirstMatch( t );
  if( docID >= 0 ) {
    Document luceneDoc = committedSearcher.doc( docID );
    // set the new doc as the existingDoc + our changes
    DocumentBuilder builder = new DocumentBuilder( schema );
    add.doc = builder.bulid( 
       this.modifyDocument( luceneDoc, cmd.doc, cmd.mode ) );
  }


- - - - - - -

This passes a new test that adds the same doc multiple times.  BUT it does 
commit each time.

Another alternative would be to keep a Map<String,Document> of the pending 
documents in memory.  Then we would not have to commit each time something has 
changed.







> Support updateable/modifiable documents
> ---------------------------------------
>
>                 Key: SOLR-139
>                 URL: https://issues.apache.org/jira/browse/SOLR-139
>             Project: Solr
>          Issue Type: Improvement
>          Components: update
>            Reporter: Ryan McKinley
>         Attachments: SOLR-139-IndexDocumentCommand.patch, 
> SOLR-139-IndexDocumentCommand.patch, SOLR-139-XmlUpdater.patch
>
>
> It would be nice to be able to update some fields on a document without 
> having to insert the entire document.
> Given the way lucene is structured, (for now) one can only modify stored 
> fields.
> While we are at it, we can support incrementing an existing value - I think 
> this only makes sense for numbers.
> for background, see:
> http://www.nabble.com/loading-many-documents-by-ID-tf3145666.html#a8722293

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to