@ Override public void search ( String words , Collection < IHelpSet > helpSets , IHelpSearchListener listener ) { try { if ( queryBuilder == null ) { initQueryBuilder ( ) ; } Query searchForWords = queryBuilder . createBooleanQuery ( "content" , words , Occur . MUST ) ; Query searchForModules = queryBuilder . createBooleanQuery ( "module" , StrUtil . fromList ( helpSets , " " ) ) ; BooleanQuery query = new BooleanQuery ( ) ; query . add ( searchForModules , Occur . MUST ) ; query . add ( searchForWords , Occur . MUST ) ; TopDocs docs = indexSearcher . search ( query , 9999 ) ; List < HelpSearchHit > hits = new ArrayList <> ( docs . totalHits ) ; for ( ScoreDoc sdoc : docs . scoreDocs ) { Document doc = indexSearcher . doc ( sdoc . doc ) ; String source = doc . get ( "source" ) ; String title = doc . get ( "title" ) ; String url = doc . get ( "url" ) ; HelpTopic topic = new HelpTopic ( new URL ( url ) , title , source ) ; HelpSearchHit hit = new HelpSearchHit ( topic , sdoc . score ) ; hits . add ( hit ) ; } listener . onSearchComplete ( hits ) ; } catch ( Exception e ) { MiscUtil . toUnchecked ( e ) ; } }
Performs a search query using the specified string on each registered query handler calling the listener for each set of results .