public List<Document> search(Query query,boolean prefixWildCard){
  List<Document> documents=new ArrayList<Document>();
  try {
    IndexSearcher searcher=getSearcher();
    TopDocs search=searcher.search(query,10000);
    for (    ScoreDoc scoreDoc : search.scoreDocs) {
      Document doc=searcher.doc(scoreDoc.doc);
      documents.add(doc);
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
    throw new RuntimeException(e);
  }
  return documents;
}

public List < Document > search ( Query query , boolean prefixWildCard ) { List < Document > documents = new ArrayList < Document > ( ) ; try { IndexSearcher searcher = getSearcher ( ) ; TopDocs search = searcher . search ( query , 10000 ) ; for ( ScoreDoc scoreDoc : search . scoreDocs ) { Document doc = searcher . doc ( scoreDoc . doc ) ; documents . add ( doc ) ; } } catch ( Exception e ) { e . printStackTrace ( ) ; throw new RuntimeException ( e ) ; } return documents ; }
searches through the index for the specified query and returns the list of documents that finds a match for the query .
