public I_CmsSearchDocument getDocument(String field, String term) {

        Document result = null;
        IndexSearcher searcher = getSearcher();
        if (searcher != null) {
            // search for an exact match on the selected field
            Term resultTerm = new Term(field, term);
            try {
                TopDocs hits = searcher.search(new TermQuery(resultTerm), 1);
                if (hits.scoreDocs.length > 0) {
                    result = searcher.doc(hits.scoreDocs[0].doc);
                }
            } catch (IOException e) {
                // ignore, return null and assume document was not found
            }
        }
        if (result != null) {
            return new CmsLuceneDocument(result);
        }
        return null;
    }
public I_CmsSearchDocument getDocument ( String field , String term ) { Document result = null ; IndexSearcher searcher = getSearcher ( ) ; if ( searcher != null ) { Term resultTerm = new Term ( field , term ) ; try { TopDocs hits = searcher . search ( new TermQuery ( resultTerm ) , 1 ) ; if ( hits . scoreDocs . length > 0 ) { result = searcher . doc ( hits . scoreDocs [ 0 ] . doc ) ; } } catch ( IOException e ) { } } if ( result != null ) { return new CmsLuceneDocument ( result ) ; } return null ; }
Returns the first document where the given term matches the selected index field.<p>

Use this method to search for documents which have unique field values, like a unique id.<p>

@param field the field to search in
@param term the term to search for

@return the first document where the given term matches the selected index field