org.elasticsearch.search.fetch.subphase.highlight.SourceScoreOrderFragmentsBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elasticsearch Show documentation
Show all versions of elasticsearch Show documentation
Elasticsearch subproject :distribution:archives:integ-test-zip
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
package org.elasticsearch.search.fetch.subphase.highlight;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.highlight.Encoder;
import org.apache.lucene.search.vectorhighlight.BoundaryScanner;
import org.apache.lucene.search.vectorhighlight.FieldFragList.WeightedFragInfo;
import org.apache.lucene.search.vectorhighlight.ScoreOrderFragmentsBuilder;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.ValueFetcher;
import org.elasticsearch.index.query.SearchExecutionContext;
import org.elasticsearch.search.lookup.SourceLookup;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class SourceScoreOrderFragmentsBuilder extends ScoreOrderFragmentsBuilder {
private final MappedFieldType fieldType;
private final SourceLookup sourceLookup;
private final ValueFetcher valueFetcher;
private final boolean fixBrokenAnalysis;
public SourceScoreOrderFragmentsBuilder(
MappedFieldType fieldType,
SearchExecutionContext context,
boolean fixBrokenAnalysis,
SourceLookup sourceLookup,
String[] preTags,
String[] postTags,
BoundaryScanner boundaryScanner
) {
super(preTags, postTags, boundaryScanner);
this.fieldType = fieldType;
this.sourceLookup = sourceLookup;
this.valueFetcher = fieldType.valueFetcher(context, null);
this.fixBrokenAnalysis = fixBrokenAnalysis;
}
@Override
protected Field[] getFields(IndexReader reader, int docId, String fieldName) throws IOException {
// we know its low level reader, and matching docId, since that's how we call the highlighter with
List