org.apache.solr.update
Class DirectUpdateHandler

java.lang.Object
  extended by org.apache.solr.update.UpdateHandler
      extended by org.apache.solr.update.DirectUpdateHandler
All Implemented Interfaces:
SolrInfoMBean

public class DirectUpdateHandler
extends UpdateHandler

DirectUpdateHandler implements an UpdateHandler where documents are added directly to the main lucene index as opposed to adding to a separate smaller index. For this reason, not all combinations to/from pending and committed are supported.

Since:
solr 0.9
Version:
$Id: DirectUpdateHandler.java 542679 2007-05-29 22:28:21Z ryan $
Author:
yonik

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.solr.core.SolrInfoMBean
SolrInfoMBean.Category
 
Field Summary
 
Fields inherited from class org.apache.solr.update.UpdateHandler
commitCallbacks, core, idField, idFieldType, log, optimizeCallbacks, schema
 
Constructor Summary
DirectUpdateHandler(SolrCore core)
           
 
Method Summary
protected  int addConditionally(AddUpdateCommand cmd)
           
 int addDoc(AddUpdateCommand cmd)
           
protected  int addNoOverwriteNoDups(AddUpdateCommand cmd)
           
protected  int allowDups(AddUpdateCommand cmd)
           
 void close()
           
protected  void closeSearcher()
           
protected  void closeWriter()
           
 void commit(CommitUpdateCommand cmd)
          old hit collector...
 void delete(DeleteUpdateCommand cmd)
          Direct update handler - pseudo code *********** def add(doc, id, allowDups, overwritePending, overwriteCommitted): if not overwritePending and not overwriteCommitted: #special case...
 void deleteByQuery(DeleteUpdateCommand cmd)
           
protected  int deleteInIndex(java.lang.String indexedId)
           
protected  void doAdd(org.apache.lucene.document.Document doc)
           
protected  boolean existsInIndex(java.lang.String indexedId)
           
 SolrInfoMBean.Category getCategory()
          Purpose of this Class
 java.lang.String getDescription()
          Simple one or two line description
 java.net.URL[] getDocs()
          Documentation URL list.
 java.lang.String getName()
          Simple common usage name, e.g.
 java.lang.String getSource()
          CVS Source, SVN Source, etc
 java.lang.String getSourceId()
          CVS Id, SVN Id, etc
 NamedList getStatistics()
          Any statistics this instance would like to be publicly available via the Solr Administration interface.
 java.lang.String getVersion()
          Simple common usage version, e.g.
protected  void openSearcher()
           
protected  void openWriter()
           
protected  void overwrite(java.lang.String indexedId, org.apache.lucene.document.Document doc)
           
protected  int overwriteBoth(AddUpdateCommand cmd)
           
 
Methods inherited from class org.apache.solr.update.UpdateHandler
callPostCommitCallbacks, callPostOptimizeCallbacks, createMainIndexWriter, getIndexedId, getIndexedIdOptional, idTerm
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectUpdateHandler

public DirectUpdateHandler(SolrCore core)
                    throws java.io.IOException
Throws:
java.io.IOException
Method Detail

openWriter

protected void openWriter()
                   throws java.io.IOException
Throws:
java.io.IOException

closeWriter

protected void closeWriter()
                    throws java.io.IOException
Throws:
java.io.IOException

openSearcher

protected void openSearcher()
                     throws java.io.IOException
Throws:
java.io.IOException

closeSearcher

protected void closeSearcher()
                      throws java.io.IOException
Throws:
java.io.IOException

doAdd

protected void doAdd(org.apache.lucene.document.Document doc)
              throws java.io.IOException
Throws:
java.io.IOException

existsInIndex

protected boolean existsInIndex(java.lang.String indexedId)
                         throws java.io.IOException
Throws:
java.io.IOException

deleteInIndex

protected int deleteInIndex(java.lang.String indexedId)
                     throws java.io.IOException
Throws:
java.io.IOException

overwrite

protected void overwrite(java.lang.String indexedId,
                         org.apache.lucene.document.Document doc)
                  throws java.io.IOException
Throws:
java.io.IOException

delete

public void delete(DeleteUpdateCommand cmd)
            throws java.io.IOException
Direct update handler - pseudo code *********** def add(doc, id, allowDups, overwritePending, overwriteCommitted): if not overwritePending and not overwriteCommitted: #special case... no need to check pending set, and we don't keep #any state around about this addition if allowDups: committed[id]=doc #100 return else: #if no dups allowed, we must check the *current* index (pending and committed) if not committed[id]: committed[id]=doc #000 return #001 (searchd addConditionally) if not allowDups and not overwritePending and pending[id]: return del committed[id] #delete from pending and committed 111 011 committed[id]=doc pending[id]=True

Specified by:
delete in class UpdateHandler
Throws:
java.io.IOException

deleteByQuery

public void deleteByQuery(DeleteUpdateCommand cmd)
                   throws java.io.IOException
Specified by:
deleteByQuery in class UpdateHandler
Throws:
java.io.IOException

commit

public void commit(CommitUpdateCommand cmd)
            throws java.io.IOException
old hit collector... new one is in base class // final DeleteHitCollector deleter = new DeleteHitCollector(); class DeleteHitCollector extends HitCollector { public int deleted=0; public void collect(int doc, float score) { try { searcher.getReader().delete(doc); deleted++; } catch (IOException e) { try { closeSearcher(); } catch (Exception ee) { SolrException.log(SolrCore.log,ee); } SolrException.log(SolrCore.log,e); throw new SolrException( SolrException.StatusCode.SERVER_ERROR,"Error deleting doc# "+doc,e); } } }

Specified by:
commit in class UpdateHandler
Throws:
java.io.IOException

addNoOverwriteNoDups

protected int addNoOverwriteNoDups(AddUpdateCommand cmd)
                            throws java.io.IOException
Throws:
java.io.IOException

addConditionally

protected int addConditionally(AddUpdateCommand cmd)
                        throws java.io.IOException
Throws:
java.io.IOException

overwriteBoth

protected int overwriteBoth(AddUpdateCommand cmd)
                     throws java.io.IOException
Throws:
java.io.IOException

allowDups

protected int allowDups(AddUpdateCommand cmd)
                 throws java.io.IOException
Throws:
java.io.IOException

addDoc

public int addDoc(AddUpdateCommand cmd)
           throws java.io.IOException
Specified by:
addDoc in class UpdateHandler
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in class UpdateHandler
Throws:
java.io.IOException

getName

public java.lang.String getName()
Description copied from interface: SolrInfoMBean
Simple common usage name, e.g. BasicQueryHandler, or fully qualified clas name.


getVersion

public java.lang.String getVersion()
Description copied from interface: SolrInfoMBean
Simple common usage version, e.g. 2.0


getDescription

public java.lang.String getDescription()
Description copied from interface: SolrInfoMBean
Simple one or two line description


getCategory

public SolrInfoMBean.Category getCategory()
Description copied from interface: SolrInfoMBean
Purpose of this Class


getSourceId

public java.lang.String getSourceId()
Description copied from interface: SolrInfoMBean
CVS Id, SVN Id, etc


getSource

public java.lang.String getSource()
Description copied from interface: SolrInfoMBean
CVS Source, SVN Source, etc


getDocs

public java.net.URL[] getDocs()
Description copied from interface: SolrInfoMBean
Documentation URL list.

Suggested documentation URLs: Homepage for sponsoring project, FAQ on class usage, Design doc for class, Wiki, bug reporting URL, etc...


getStatistics

public NamedList getStatistics()
Description copied from interface: SolrInfoMBean
Any statistics this instance would like to be publicly available via the Solr Administration interface.

Any Object type may be stored in the list, but only the toString() representation will be used.



Copyright © 2006 - 2009 The Apache Software Foundation