lucene-solr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Hostetter <hossman_luc...@fucit.org>
Subject Re: getDocumentByUniqueKey()
Date Mon, 07 May 2007 00:09:17 GMT

i've got no objection to the concept, didn't really look too hard at the
code though ... it should probably be documented to through an exception
if the schema has no uniqueKey definition though (returning null definitly
seems like hte wrong behavior)

: Date: Sat, 05 May 2007 16:38:48 -0400
: From: Ryan McKinley <ryantxu@gmail.com>
: Reply-To: solr-dev@lucene.apache.org
: To: solr-dev@lucene.apache.org
: Subject: getDocumentByUniqueKey()
:
:
: I find myself wanting to get a single Document by ID often.
:
: 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;
:    }
:
:
: This will be needed for SOLR-139, the modifiable Document command.
:
:
: ryan
:
:



-Hoss


Mime
View raw message