}
int start = params.getInt( CommonParams.START, 0 );
int rows = params.getInt( CommonParams.ROWS, 10 );
DocListAndSet mltDocs = null;
// Find documents MoreLikeThis - either with a reader or a query
//--------------------------------------------------------------------------------
if( reader != null ) {
mltDocs = mlt.getMoreLikeThis( reader, start, rows, filters, interesting, flags );
}
else if( q != null ) {
// Matching options
boolean includeMatch = params.getBool( MoreLikeThisParams.MATCH_INCLUDE, true );
int matchOffset = params.getInt( MoreLikeThisParams.MATCH_OFFSET, 0 );
// Find the base match
Query query = QueryParsing.parseQuery(q, params.get(CommonParams.DF), params, req.getSchema());
DocList match = searcher.getDocList(query, null, null, matchOffset, 1, flags ); // only get the first one...
if( includeMatch ) {
rsp.add( "match", match );
}
// This is an iterator, but we only handle the first match
DocIterator iterator = match.iterator();
if( iterator.hasNext() ) {
// do a MoreLikeThis query for each document in results
int id = iterator.nextDoc();
mltDocs = mlt.getMoreLikeThis( id, start, rows, filters, interesting, flags );
}
}
else {
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST,
"MoreLikeThis requires either a query (?q=) or text to find similar documents." );
}
if( mltDocs == null ) {
mltDocs = new DocListAndSet(); // avoid NPE
}
rsp.add( "response", mltDocs.docList );
if( interesting != null ) {