Example usage for org.apache.lucene.search.vectorhighlight FastVectorHighlighter getBestFragments

List of usage examples for org.apache.lucene.search.vectorhighlight FastVectorHighlighter getBestFragments

Introduction

In this page you can find the example usage for org.apache.lucene.search.vectorhighlight FastVectorHighlighter getBestFragments.

Prototype

public final String[] getBestFragments(final FieldQuery fieldQuery, IndexReader reader, int docId,
        String fieldName, int fragCharSize, int maxNumFragments, FragListBuilder fragListBuilder,
        FragmentsBuilder fragmentsBuilder, String[] preTags, String[] postTags, Encoder encoder)
        throws IOException 

Source Link

Document

return the best fragments.

Usage

From source file:org.apache.solr.highlight.DefaultSolrHighlighter.java

License:Apache License

private void doHighlightingByFastVectorHighlighter(FastVectorHighlighter highlighter, FieldQuery fieldQuery,
        SolrQueryRequest req, NamedList docSummaries, int docId, Document doc, String fieldName)
        throws IOException {
    SolrParams params = req.getParams();
    SolrFragmentsBuilder solrFb = getSolrFragmentsBuilder(fieldName, params);
    String[] snippets = highlighter.getBestFragments(fieldQuery, req.getSearcher().getIndexReader(), docId,
            fieldName, params.getFieldInt(fieldName, HighlightParams.FRAGSIZE, 100),
            params.getFieldInt(fieldName, HighlightParams.SNIPPETS, 1), getFragListBuilder(fieldName, params),
            getFragmentsBuilder(fieldName, params), solrFb.getPreTags(params, fieldName),
            solrFb.getPostTags(params, fieldName), getEncoder(fieldName, params));
    if (snippets != null && snippets.length > 0)
        docSummaries.add(fieldName, snippets);
    else/*from   w ww  .j a va  2 s.c  o m*/
        alternateField(docSummaries, params, doc, fieldName);
}