private static HighlightBuilder.Field createHighlighterField() { HighlightBuilder.Field field = new HighlightBuilder.Field(FIELD_NAME); field.highlighterType("fvh"); field.matchedFields( Stream.concat( Stream.of(FIELD_NAME), Arrays .stream(NAME_ANALYZERS) .map(a -> a.subField(FIELD_NAME))) .toArray(String[]::new)); return field; }
HighlightBuilder.Field field = new HighlightBuilder.Field(params[0].toString()); if (params.length == 1) { return field;
private static HighlightBuilder.Field createHighlighterField() { HighlightBuilder.Field field = new HighlightBuilder.Field(FIELD_NAME); field.highlighterType("fvh"); field.matchedFields( Stream.concat( Stream.of(FIELD_NAME), Arrays .stream(NAME_ANALYZERS) .map(a -> a.subField(FIELD_NAME))) .toArray(String[]::new)); return field; }
@Override public Field rewrite(QueryRewriteContext ctx) throws IOException { if (highlightQuery != null) { QueryBuilder rewrite = highlightQuery.rewrite(ctx); if (rewrite != highlightQuery) { return new Field(this, rewrite); } } return this; } }
/** * Adds a field to be highlighted with default fragment size of 100 characters, and * default number of fragments of 5 using the default encoder * * @param name The field to highlight */ public HighlightBuilder field(String name) { return field(new Field(name)); }
/** * Adds a field to be highlighted with a provided fragment size (in characters), and * default number of fragments of 5. * * @param name The field to highlight * @param fragmentSize The size of a fragment in characters */ public HighlightBuilder field(String name, int fragmentSize) { return field(new Field(name).fragmentSize(fragmentSize)); }
/** * Read from a stream. */ public HighlightBuilder(StreamInput in) throws IOException { super(in); encoder(in.readOptionalString()); useExplicitFieldOrder(in.readBoolean()); int fields = in.readVInt(); for (int i = 0; i < fields; i++) { field(new Field(in)); } }
/** * Read from a stream. */ public Field(StreamInput in) throws IOException { super(in); name = in.readString(); fragmentOffset(in.readVInt()); matchedFields(in.readOptionalStringArray()); assert this.equals(new Field(this, highlightQuery)) : "copy constructor is broken"; }
/** * Read from a stream. */ public Field(StreamInput in) throws IOException { super(in); name = in.readString(); fragmentOffset(in.readVInt()); matchedFields(in.readOptionalStringArray()); assert this.equals(new Field(this, highlightQuery)) : "copy constructor is broken"; }
/** * Adds a field to be highlighted with a provided fragment size (in characters), and * a provided (maximum) number of fragments. * * @param name The field to highlight * @param fragmentSize The size of a fragment in characters * @param numberOfFragments The (maximum) number of fragments */ public HighlightBuilder field(String name, int fragmentSize, int numberOfFragments) { return field(new Field(name).fragmentSize(fragmentSize).numOfFragments(numberOfFragments)); }
/** * Adds a field to be highlighted with default fragment size of 100 characters, and * default number of fragments of 5 using the default encoder * * @param name The field to highlight */ public HighlightBuilder field(String name) { return field(new Field(name)); }
@Override public Field rewrite(QueryRewriteContext ctx) throws IOException { if (highlightQuery != null) { QueryBuilder rewrite = highlightQuery.rewrite(ctx); if (rewrite != highlightQuery) { return new Field(this, rewrite); } } return this; } }
/** * Adds a field to be highlighted with a provided fragment size (in characters), and * a provided (maximum) number of fragments. * * @param name The field to highlight * @param fragmentSize The size of a fragment in characters * @param numberOfFragments The (maximum) number of fragments */ public HighlightBuilder field(String name, int fragmentSize, int numberOfFragments) { return field(new Field(name).fragmentSize(fragmentSize).numOfFragments(numberOfFragments)); }
/** * Adds a field to be highlighted with a provided fragment size (in characters), and * default number of fragments of 5. * * @param name The field to highlight * @param fragmentSize The size of a fragment in characters */ public HighlightBuilder field(String name, int fragmentSize) { return field(new Field(name).fragmentSize(fragmentSize)); }
/** * Adds a field to be highlighted with a provided fragment size (in characters), and * a provided (maximum) number of fragments. * * @param name The field to highlight * @param fragmentSize The size of a fragment in characters * @param numberOfFragments The (maximum) number of fragments * @param fragmentOffset The offset from the start of the fragment to the start of the highlight */ public HighlightBuilder field(String name, int fragmentSize, int numberOfFragments, int fragmentOffset) { return field(new Field(name).fragmentSize(fragmentSize).numOfFragments(numberOfFragments) .fragmentOffset(fragmentOffset)); }
/** * Adds a field to be highlighted with a provided fragment size (in characters), and * a provided (maximum) number of fragments. * * @param name The field to highlight * @param fragmentSize The size of a fragment in characters * @param numberOfFragments The (maximum) number of fragments */ public HighlightBuilder field(String name, int fragmentSize, int numberOfFragments) { return field(new Field(name).fragmentSize(fragmentSize).numOfFragments(numberOfFragments)); }
/** * Adds a field to be highlighted with a provided fragment size (in characters), and * default number of fragments of 5. * * @param name The field to highlight * @param fragmentSize The size of a fragment in characters */ public HighlightBuilder field(String name, int fragmentSize) { return field(new Field(name).fragmentSize(fragmentSize)); }
/** * Adds a field to be highlighted with default fragment size of 100 characters, and * default number of fragments of 5 using the default encoder * * @param name The field to highlight */ public HighlightBuilder field(String name) { return field(new Field(name)); }
@Override public Field rewrite(QueryRewriteContext ctx) throws IOException { if (highlightQuery != null) { QueryBuilder rewrite = highlightQuery.rewrite(ctx); if (rewrite != highlightQuery) { return new Field(this, rewrite); } } return this; } }
/** * Read from a stream. */ public Field(StreamInput in) throws IOException { super(in); name = in.readString(); fragmentOffset(in.readVInt()); matchedFields(in.readOptionalStringArray()); assert this.equals(new Field(this, highlightQuery)) : "copy constructor is broken"; }