On 5/5/07, Ryan McKinley <[EMAIL PROTECTED]> wrote:
I find myself wanting to get a single Document by ID often.

But sometimes the ID will already be in indexed form, sometimes
you will only want to get certain fields, etc.
I think it might be better as a convenience function somewhere, rather
than expanding the interface of SolrIndexSearcher even more.

-Yonik

How do you all feel about adding this (or something like it) to
SolrIndexSearcher?


   public Document getDocumentByUniqueKey( String id ) throws IOException
   {
     SchemaField uniqueKey = schema.getUniqueKeyField();
     if( uniqueKey != null ) {
       Term t = new Term( uniqueKey.getName(),
           uniqueKey.getType().toInternal( id.toString() ) );
       int docID = getFirstMatch( t );
       if( docID >= 0 ) {
         return doc( docID );
       }
     }
     return null;
   }

Reply via email to