@Override protected void innerReadFrom(StreamInput in) throws IOException { super.innerReadFrom(in); sort = SortBy.readFromStream(in); }
@Override public void innerWriteTo(StreamOutput out) throws IOException { super.innerWriteTo(out); sort.writeTo(out); }
/** * Same as {@link #prefix(String)} with full fuzzy options * see {@link FuzzyOptions.Builder} */ public CompletionSuggestionBuilder prefix(String prefix, FuzzyOptions fuzzyOptions) { super.prefix(prefix); this.fuzzyOptions = fuzzyOptions; return this; }
/** * Same as {@link #prefix(String)} with fuzziness of <code>fuzziness</code> */ public CompletionSuggestionBuilder prefix(String prefix, Fuzziness fuzziness) { super.prefix(prefix); this.fuzzyOptions = new FuzzyOptions.Builder().setFuzziness(fuzziness).build(); return this; }
@Override public void readFrom(StreamInput in) throws IOException { innerReadFrom(in); int size = in.readVInt(); entries.clear(); for (int i = 0; i < size; i++) { T newEntry = newEntry(); newEntry.readFrom(in); entries.add(newEntry); } }
@Override public void writeTo(StreamOutput out) throws IOException { innerWriteTo(out); out.writeVInt(entries.size()); for (Entry<?> entry : entries) { entry.writeTo(out); } }
protected void addOptions(List<O> options) { for (O option : options) { addOption(option); } }
@SuppressWarnings("unchecked") protected O newOption(){ return (O) new Option(); }
protected T newEntry() { return (T)new Entry(); }
@Override protected void mergeInto(Suggestion.Entry.Option otherOption) { super.mergeInto(otherOption); freq += ((Option) otherOption).freq; }
/** * Trims the number of options per suggest text term to the requested size. * For internal usage. */ public void trim() { for (Entry<?> entry : entries) { entry.trim(size); } }
@Override public void addOption(Suggestion.Entry.Option option) { if (option.getScore() > this.cutoffScore) { this.options.add(option); } }
@Override public void readFrom(StreamInput in) throws IOException { super.readFrom(in); freq = in.readVInt(); }
@Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeDouble(cutoffScore); } }
/** * Returns <code>true</code> if this result has any suggest score docs */ public boolean hasSuggestHits() { return (suggest != null && suggest.hasScoreDocs()); }
/** * Sets a regular expression pattern for prefixes to provide completions for. */ @Override public CompletionSuggestionBuilder regex(String regex) { super.regex(regex); return this; }
private String getSuggesterName() { //default impl returns the same as writeable name, but we keep the distinction between the two just to make sure return getWriteableName(); }
@Override public String toString() { return "SpellcheckerSettings" + settings + ", BaseSettings" + super.toString(); }
/** * Sets the prefix to provide completions for. * The prefix gets analyzed by the suggest analyzer. */ @Override public CompletionSuggestionBuilder prefix(String prefix) { super.prefix(prefix); return this; }