Search in sources :

Example 1 with Summarizer

use of org.opengrok.indexer.search.Summarizer in project OpenGrok by OpenGrok.

the class SearchHelper method prepareSummary.

/**
 * Prepare the fields to support printing a full blown summary. Does nothing
 * if {@link #redirect} or {@link #errorMsg} have a none-{@code null} value.
 *
 * <p>
 * Parameters which should be populated/set at this time: <ul>
 * <li>{@link #query}</li> <li>{@link #builder}</li> </ul> Populates/sets:
 * Otherwise the following fields are set (includes {@code null}): <ul>
 * <li>{@link #sourceContext}</li> <li>{@link #summarizer}</li>
 * <li>{@link #historyContext}</li> </ul>
 *
 * @return this instance.
 */
public SearchHelper prepareSummary() {
    if (redirect != null || errorMsg != null) {
        return this;
    }
    try {
        sourceContext = new Context(query, builder);
        summarizer = new Summarizer(query, new CompatibleAnalyser());
    } catch (Exception e) {
        LOGGER.log(Level.WARNING, "Summarizer: {0}", e.getMessage());
    }
    try {
        historyContext = new HistoryContext(query);
    } catch (Exception e) {
        LOGGER.log(Level.WARNING, "HistoryContext: {0}", e.getMessage());
    }
    return this;
}
Also used : HistoryContext(org.opengrok.indexer.search.context.HistoryContext) Context(org.opengrok.indexer.search.context.Context) LeafReaderContext(org.apache.lucene.index.LeafReaderContext) CompatibleAnalyser(org.opengrok.indexer.analysis.CompatibleAnalyser) HistoryContext(org.opengrok.indexer.search.context.HistoryContext) Summarizer(org.opengrok.indexer.search.Summarizer) ForbiddenSymlinkException(org.opengrok.indexer.util.ForbiddenSymlinkException) FileNotFoundException(java.io.FileNotFoundException) ParseException(org.apache.lucene.queryparser.classic.ParseException) IOException(java.io.IOException)

Aggregations

FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 LeafReaderContext (org.apache.lucene.index.LeafReaderContext)1 ParseException (org.apache.lucene.queryparser.classic.ParseException)1 CompatibleAnalyser (org.opengrok.indexer.analysis.CompatibleAnalyser)1 Summarizer (org.opengrok.indexer.search.Summarizer)1 Context (org.opengrok.indexer.search.context.Context)1 HistoryContext (org.opengrok.indexer.search.context.HistoryContext)1 ForbiddenSymlinkException (org.opengrok.indexer.util.ForbiddenSymlinkException)1