if (nGramSize > 1) { //<co id="mlt.ngramsetup"/>
analyzer = new ShingleAnalyzerWrapper(analyzer, nGramSize,
nGramSize);
}
MoreLikeThis moreLikeThis = new MoreLikeThis(indexReader); //<co id="mlt.configure"/>
moreLikeThis.setAnalyzer(analyzer);
moreLikeThis.setFieldNames(new String[] {
"content"
});
/*<calloutlist>
<callout arearefs="mlt.indexsetup">Open Index</callout>
<callout arearefs="mlt.analyzersetup">Setup Analyzer</callout>
<callout arearefs="mlt.ngramsetup">Setup NGrams</callout>
<callout arearefs="mlt.configure">Create <classname>MoreLikeThis</classname></callout>
</calloutlist>*/
//<end id="lucene.examples.mlt.setup"/>
// for testing against the same corpus
moreLikeThis.setMinTermFreq(1);
moreLikeThis.setMinDocFreq(1);
//<start id="lucene.examples.mlt.query"/>
Reader reader = new FileReader(inputPath); //<co id="mlt.query"/>
Query query = moreLikeThis.like(reader);
TopDocs results
= indexSearcher.search(query, maxResults); //<co id="mlt.search"/>
HashMap<String, CategoryHits> categoryHash