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


Reply via email to