public static CompletionSuggestion fromXContent(XContentParser parser, String name) throws IOException { CompletionSuggestion suggestion = new CompletionSuggestion(name, -1, false); parseEntries(parser, suggestion, CompletionSuggestion.Entry::fromXContent); return suggestion; }
public FuzzyOptions build() { return new FuzzyOptions(editDistance, transpositions, fuzzyMinLength, fuzzyPrefixLength, unicodeAware, maxDeterminizedStates); } }
/** * 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; }
public static CompletionSuggestionBuilder fromXContent(XContentParser parser) throws IOException { CompletionSuggestionBuilder.InnerBuilder builder = new CompletionSuggestionBuilder.InnerBuilder(); PARSER.parse(parser, builder, null); String field = builder.field; // now we should have field name, check and copy fields over to the suggestion builder we return if (field == null) { throw new ElasticsearchParseException( "the required field option [" + FIELDNAME_FIELD.getPreferredName() + "] is missing"); } return new CompletionSuggestionBuilder(field, builder); }
public void setShardIndex(int shardIndex) { if (entries.isEmpty() == false) { for (Entry.Option option : getOptions()) { option.setShardIndex(shardIndex); } } }
/** * Creates a completion suggestion lookup query with the provided <code>field</code> * * @return a {@link org.elasticsearch.search.suggest.completion.CompletionSuggestionBuilder} * instance */ public static CompletionSuggestionBuilder completionSuggestion(String fieldname) { return new CompletionSuggestionBuilder(fieldname); } }
/** * Same as {@link #regex(String)} with full regular expression options * see {@link RegexOptions.Builder} */ public CompletionSuggestionBuilder regex(String regex, RegexOptions regexOptions) { this.regex(regex); this.regexOptions = regexOptions; return this; }
@Override protected Option newOption() { return new Option(); }
@Override protected Entry newEntry() { return new Entry(); }
/** * @return whether there is any hits for the suggestion */ public boolean hasScoreDocs() { return getOptions().size() > 0; }
static RegexOptions parse(XContentParser parser) throws IOException { return PARSER.parse(parser, null).build(); }
public void add(CompletionStats completion) { if (completion == null) { return; } sizeInBytes += completion.getSizeInBytes(); if (completion.fields != null) { if (fields == null) { fields = completion.fields.copy(); } else { fields.add(completion.fields); } } } }
@Override public Suggest.Suggestion<Entry> reduce(List<Suggest.Suggestion<Entry>> toReduce) { return reduceTo(toReduce); }
public RegexOptions build() { return new RegexOptions(flagsValue, maxDeterminizedStates); } }
public static Builder builder() { return new Builder(); }
public static Builder builder() { return new Builder(); }
static FuzzyOptions parse(XContentParser parser) throws IOException { return PARSER.parse(parser, null).build(); }
/** * Sets the level of fuzziness used to create suggestions using a {@link Fuzziness} instance. * The default value is {@link Fuzziness#ONE} which allows for an "edit distance" of one. */ public Builder setFuzziness(Fuzziness fuzziness) { Objects.requireNonNull(fuzziness, "fuzziness must not be null"); return setFuzziness(fuzziness.asDistance()); }