Example usage for org.apache.lucene.search.vectorhighlight FieldPhraseList FieldPhraseList

List of usage examples for org.apache.lucene.search.vectorhighlight FieldPhraseList FieldPhraseList

Introduction

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

Prototype

public FieldPhraseList(FieldTermStack fieldTermStack, FieldQuery fieldQuery, int phraseLimit) 

Source Link

Document

a constructor.

Usage

From source file:com.github.hotware.lucene.extension.highlight.FVHighlighterUtil.java

License:BEER-WARE LICENSE

/**
 * Build a FieldFragList for more than one field.
 *///from ww  w . ja  v  a2 s . c  om
public FieldFragList getFieldFragList(final FieldQuery fieldQuery, IndexReader reader, int docId,
        Set<String> matchedFields, int fragCharSize) throws IOException {
    Iterator<String> matchedFieldsItr = matchedFields.iterator();
    if (!matchedFieldsItr.hasNext()) {
        throw new IllegalArgumentException("matchedFields must contain at least one field name.");
    }
    FieldPhraseList[] toMerge = new FieldPhraseList[matchedFields.size()];
    int i = 0;
    while (matchedFieldsItr.hasNext()) {
        FieldTermStack stack = new FieldTermStack(reader, docId, matchedFieldsItr.next(), fieldQuery);
        toMerge[i++] = new FieldPhraseList(stack, fieldQuery, this.phraseLimit);
    }
    return this.fragListBuilder.createFieldFragList(new FieldPhraseList(toMerge), fragCharSize);
}