All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.arakelian.elastic.model.search.ImmutableMoreLikeThisQuery Maven / Gradle / Ivy

package com.arakelian.elastic.model.search;

import com.arakelian.core.feature.Nullable;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import javax.annotation.CheckReturnValue;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import org.immutables.value.Generated;

/**
 * Immutable implementation of {@link MoreLikeThisQuery}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableMoreLikeThisQuery.builder()}. */ @Generated(from = "MoreLikeThisQuery", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableMoreLikeThisQuery implements MoreLikeThisQuery { private final @Nullable String analyzer; private final @Nullable Float boostTerms; private final ImmutableSet fields; private final ImmutableList likeItems; private final ImmutableList likeTexts; private final @Nullable Integer maxDocFrequency; private final @Nullable Integer maxQueryTerms; private final @Nullable Integer maxWordLength; private final @Nullable Integer minDocFrequency; private final @Nullable String minimumShouldMatch; private final @Nullable Integer minTermFrequency; private final @Nullable Integer minWordLength; private final ImmutableSet stopWords; private final ImmutableList unlikeItems; private final ImmutableList unlikeTexts; private final @Nullable Boolean failOnUnsupportedField; private final @Nullable Boolean include; private final @Nullable Float boost; private final @Nullable String name; private final boolean hasStandardDefaults; private ImmutableMoreLikeThisQuery(ImmutableMoreLikeThisQuery.Builder builder) { this.analyzer = builder.analyzer; this.boostTerms = builder.boostTerms; this.maxDocFrequency = builder.maxDocFrequency; this.maxQueryTerms = builder.maxQueryTerms; this.maxWordLength = builder.maxWordLength; this.minDocFrequency = builder.minDocFrequency; this.minimumShouldMatch = builder.minimumShouldMatch; this.minTermFrequency = builder.minTermFrequency; this.minWordLength = builder.minWordLength; this.failOnUnsupportedField = builder.failOnUnsupportedField; this.include = builder.include; this.boost = builder.boost; this.name = builder.name; if (builder.fieldsIsSet()) { initShim.fields(builder.fields.build()); } if (builder.likeItemsIsSet()) { initShim.likeItems(builder.likeItems.build()); } if (builder.likeTextsIsSet()) { initShim.likeTexts(builder.likeTexts.build()); } if (builder.stopWordsIsSet()) { initShim.stopWords(builder.stopWords.build()); } if (builder.unlikeItemsIsSet()) { initShim.unlikeItems(builder.unlikeItems.build()); } if (builder.unlikeTextsIsSet()) { initShim.unlikeTexts(builder.unlikeTexts.build()); } this.fields = initShim.getFields(); this.likeItems = initShim.getLikeItems(); this.likeTexts = initShim.getLikeTexts(); this.stopWords = initShim.getStopWords(); this.unlikeItems = initShim.getUnlikeItems(); this.unlikeTexts = initShim.getUnlikeTexts(); this.hasStandardDefaults = initShim.hasStandardDefaults(); this.initShim = null; } private static final byte STAGE_INITIALIZING = -1; private static final byte STAGE_UNINITIALIZED = 0; private static final byte STAGE_INITIALIZED = 1; @SuppressWarnings("Immutable") private transient volatile InitShim initShim = new InitShim(); @Generated(from = "MoreLikeThisQuery", generator = "Immutables") private final class InitShim { private byte fieldsBuildStage = STAGE_UNINITIALIZED; private ImmutableSet fields; ImmutableSet getFields() { if (fieldsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (fieldsBuildStage == STAGE_UNINITIALIZED) { fieldsBuildStage = STAGE_INITIALIZING; this.fields = ImmutableSet.copyOf(getFieldsInitialize()); fieldsBuildStage = STAGE_INITIALIZED; } return this.fields; } void fields(ImmutableSet fields) { this.fields = fields; fieldsBuildStage = STAGE_INITIALIZED; } private byte likeItemsBuildStage = STAGE_UNINITIALIZED; private ImmutableList likeItems; ImmutableList getLikeItems() { if (likeItemsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (likeItemsBuildStage == STAGE_UNINITIALIZED) { likeItemsBuildStage = STAGE_INITIALIZING; this.likeItems = ImmutableList.copyOf(getLikeItemsInitialize()); likeItemsBuildStage = STAGE_INITIALIZED; } return this.likeItems; } void likeItems(ImmutableList likeItems) { this.likeItems = likeItems; likeItemsBuildStage = STAGE_INITIALIZED; } private byte likeTextsBuildStage = STAGE_UNINITIALIZED; private ImmutableList likeTexts; ImmutableList getLikeTexts() { if (likeTextsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (likeTextsBuildStage == STAGE_UNINITIALIZED) { likeTextsBuildStage = STAGE_INITIALIZING; this.likeTexts = ImmutableList.copyOf(getLikeTextsInitialize()); likeTextsBuildStage = STAGE_INITIALIZED; } return this.likeTexts; } void likeTexts(ImmutableList likeTexts) { this.likeTexts = likeTexts; likeTextsBuildStage = STAGE_INITIALIZED; } private byte stopWordsBuildStage = STAGE_UNINITIALIZED; private ImmutableSet stopWords; ImmutableSet getStopWords() { if (stopWordsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (stopWordsBuildStage == STAGE_UNINITIALIZED) { stopWordsBuildStage = STAGE_INITIALIZING; this.stopWords = ImmutableSet.copyOf(getStopWordsInitialize()); stopWordsBuildStage = STAGE_INITIALIZED; } return this.stopWords; } void stopWords(ImmutableSet stopWords) { this.stopWords = stopWords; stopWordsBuildStage = STAGE_INITIALIZED; } private byte unlikeItemsBuildStage = STAGE_UNINITIALIZED; private ImmutableList unlikeItems; ImmutableList getUnlikeItems() { if (unlikeItemsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (unlikeItemsBuildStage == STAGE_UNINITIALIZED) { unlikeItemsBuildStage = STAGE_INITIALIZING; this.unlikeItems = ImmutableList.copyOf(getUnlikeItemsInitialize()); unlikeItemsBuildStage = STAGE_INITIALIZED; } return this.unlikeItems; } void unlikeItems(ImmutableList unlikeItems) { this.unlikeItems = unlikeItems; unlikeItemsBuildStage = STAGE_INITIALIZED; } private byte unlikeTextsBuildStage = STAGE_UNINITIALIZED; private ImmutableList unlikeTexts; ImmutableList getUnlikeTexts() { if (unlikeTextsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (unlikeTextsBuildStage == STAGE_UNINITIALIZED) { unlikeTextsBuildStage = STAGE_INITIALIZING; this.unlikeTexts = ImmutableList.copyOf(getUnlikeTextsInitialize()); unlikeTextsBuildStage = STAGE_INITIALIZED; } return this.unlikeTexts; } void unlikeTexts(ImmutableList unlikeTexts) { this.unlikeTexts = unlikeTexts; unlikeTextsBuildStage = STAGE_INITIALIZED; } private byte hasStandardDefaultsBuildStage = STAGE_UNINITIALIZED; private boolean hasStandardDefaults; boolean hasStandardDefaults() { if (hasStandardDefaultsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (hasStandardDefaultsBuildStage == STAGE_UNINITIALIZED) { hasStandardDefaultsBuildStage = STAGE_INITIALIZING; this.hasStandardDefaults = hasStandardDefaultsInitialize(); hasStandardDefaultsBuildStage = STAGE_INITIALIZED; } return this.hasStandardDefaults; } private String formatInitCycleMessage() { List attributes = new ArrayList<>(); if (fieldsBuildStage == STAGE_INITIALIZING) attributes.add("fields"); if (likeItemsBuildStage == STAGE_INITIALIZING) attributes.add("likeItems"); if (likeTextsBuildStage == STAGE_INITIALIZING) attributes.add("likeTexts"); if (stopWordsBuildStage == STAGE_INITIALIZING) attributes.add("stopWords"); if (unlikeItemsBuildStage == STAGE_INITIALIZING) attributes.add("unlikeItems"); if (unlikeTextsBuildStage == STAGE_INITIALIZING) attributes.add("unlikeTexts"); if (hasStandardDefaultsBuildStage == STAGE_INITIALIZING) attributes.add("hasStandardDefaults"); return "Cannot build MoreLikeThisQuery, attribute initializers form cycle " + attributes; } } private Set getFieldsInitialize() { return MoreLikeThisQuery.super.getFields(); } private List getLikeItemsInitialize() { return MoreLikeThisQuery.super.getLikeItems(); } private List getLikeTextsInitialize() { return MoreLikeThisQuery.super.getLikeTexts(); } private Set getStopWordsInitialize() { return MoreLikeThisQuery.super.getStopWords(); } private List getUnlikeItemsInitialize() { return MoreLikeThisQuery.super.getUnlikeItems(); } private List getUnlikeTextsInitialize() { return MoreLikeThisQuery.super.getUnlikeTexts(); } private boolean hasStandardDefaultsInitialize() { return MoreLikeThisQuery.super.hasStandardDefaults(); } /** * Returns the analyzer that is used to analyze the free form text. Defaults to the analyzer * associated with the first field in fields * @return the analyzer that is used to analyze the free form text */ @JsonProperty("analyzer") @Override public @Nullable String getAnalyzer() { return analyzer; } /** * Returns the additional boost for each term in the formed query. Defaults to deactivated (0). * Any other positive value activates terms boosting with the given boost factor. * @return the additional boost for each term in the formed query */ @JsonProperty("boost_terms") @Override public @Nullable Float getBoostTerms() { return boostTerms; } /** * @return The value of the {@code fields} attribute */ @JsonProperty("fields") @Override public ImmutableSet getFields() { InitShim shim = this.initShim; return shim != null ? shim.getFields() : this.fields; } /** * @return The value of the {@code likeItems} attribute */ @JsonProperty("like_items") @Override public ImmutableList getLikeItems() { InitShim shim = this.initShim; return shim != null ? shim.getLikeItems() : this.likeItems; } /** * @return The value of the {@code likeTexts} attribute */ @JsonProperty("like_texts") @Override public ImmutableList getLikeTexts() { InitShim shim = this.initShim; return shim != null ? shim.getLikeTexts() : this.likeTexts; } /** * Returns the maximum document frequency above which the terms will be ignored from the input * document. This could be useful in order to ignore highly frequent words such as stop words. * Defaults to unbounded (0) * @return the maximum document frequency above which the terms will be ignored from the input * document */ @JsonProperty("max_doc_freq") @Override public @Nullable Integer getMaxDocFrequency() { return maxDocFrequency; } /** * Returns the maximum number of query terms that will be selected. Increasing this value gives * greater accuracy at the expense of query execution speed. Defaults to 25. * @return the maximum number of query terms that will be selected */ @JsonProperty("max_query_terms") @Override public @Nullable Integer getMaxQueryTerms() { return maxQueryTerms; } /** * Returns the maximum word length above which the terms will be ignored. Defaults to unbounded * (0) * @return the maximum word length above which the terms will be ignored */ @JsonProperty("max_word_length") @Override public @Nullable Integer getMaxWordLength() { return maxWordLength; } /** * Returns the minimum document frequency below which the terms will be ignored from the input * document. Defaults to 5 * @return the minimum document frequency below which the terms will be ignored from the input * document */ @JsonProperty("min_doc_freq") @Override public @Nullable Integer getMinDocFrequency() { return minDocFrequency; } /** * Returns the number of terms that must match after the disjunctive query has been formed. The * syntax is the same as the minimum should match. (Defaults to "30%"). * @return the number of terms that must match after the disjunctive query has been formed */ @JsonProperty("minimum_should_match") @Override public @Nullable String getMinimumShouldMatch() { return minimumShouldMatch; } /** * Returns the minimum term frequency below which the terms will be ignored from the input * document. Defaults to 2 * @return the minimum term frequency below which the terms will be ignored from the input * document */ @JsonProperty("min_term_freq") @Override public @Nullable Integer getMinTermFrequency() { return minTermFrequency; } /** * Returns the minimum word length below which the terms will be ignored. Defaults to 0 * @return the minimum word length below which the terms will be ignored */ @JsonProperty("min_word_length") @Override public @Nullable Integer getMinWordLength() { return minWordLength; } /** * Returns an array of stop words. Any word in this set is considered "uninteresting" and * ignored. If the analyzer allows for stop words, you might want to tell MLT to explicitly * ignore them, as for the purposes of document similarity it seems reasonable to assume that "a * stop word is never interesting". * @return an array of stop words */ @JsonProperty("stop_words") @Override public ImmutableSet getStopWords() { InitShim shim = this.initShim; return shim != null ? shim.getStopWords() : this.stopWords; } /** * @return The value of the {@code unlikeItems} attribute */ @JsonProperty("unlike_items") @Override public ImmutableList getUnlikeItems() { InitShim shim = this.initShim; return shim != null ? shim.getUnlikeItems() : this.unlikeItems; } /** * @return The value of the {@code unlikeTexts} attribute */ @JsonProperty("unlike_texts") @Override public ImmutableList getUnlikeTexts() { InitShim shim = this.initShim; return shim != null ? shim.getUnlikeTexts() : this.unlikeTexts; } /** * Returns true if query should fail (throw an exception) if any of the specified fields are not * of the supported types (text or keyword'). Set this to `false to ignore the field and * continue processing. Defaults to true. * @return true if query should fail if any of the specified fields are not of the supported * types (text or keyword') */ @JsonProperty("fail_on_unsupported_field") @Override public @Nullable Boolean isFailOnUnsupportedField() { return failOnUnsupportedField; } /** * Returns whether the input documents should also be included in the search results returned. * Defaults to false * @return whether the input documents should also be included in the search results returned */ @JsonProperty("include") @Override public @Nullable Boolean isInclude() { return include; } /** * @return The value of the {@code boost} attribute */ @JsonProperty("boost") @Override public @Nullable Float getBoost() { return boost; } /** * Returns the name of the query * @return name of the query * @see Named * Queries */ @JsonProperty("_name") @Override public @Nullable String getName() { return name; } /** * @return The computed-at-construction value of the {@code hasStandardDefaults} attribute */ @JsonProperty("hasStandardDefaults") @JsonIgnore @Override public boolean hasStandardDefaults() { InitShim shim = this.initShim; return shim != null ? shim.hasStandardDefaults() : this.hasStandardDefaults; } /** * This instance is equal to all instances of {@code ImmutableMoreLikeThisQuery} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(@javax.annotation.Nullable Object another) { if (this == another) return true; return another instanceof ImmutableMoreLikeThisQuery && equalTo((ImmutableMoreLikeThisQuery) another); } private boolean equalTo(ImmutableMoreLikeThisQuery another) { return Objects.equals(analyzer, another.analyzer) && Objects.equals(boostTerms, another.boostTerms) && fields.equals(another.fields) && likeItems.equals(another.likeItems) && likeTexts.equals(another.likeTexts) && Objects.equals(maxDocFrequency, another.maxDocFrequency) && Objects.equals(maxQueryTerms, another.maxQueryTerms) && Objects.equals(maxWordLength, another.maxWordLength) && Objects.equals(minDocFrequency, another.minDocFrequency) && Objects.equals(minimumShouldMatch, another.minimumShouldMatch) && Objects.equals(minTermFrequency, another.minTermFrequency) && Objects.equals(minWordLength, another.minWordLength) && stopWords.equals(another.stopWords) && unlikeItems.equals(another.unlikeItems) && unlikeTexts.equals(another.unlikeTexts) && Objects.equals(failOnUnsupportedField, another.failOnUnsupportedField) && Objects.equals(include, another.include) && Objects.equals(boost, another.boost) && Objects.equals(name, another.name); } /** * Computes a hash code from attributes: {@code analyzer}, {@code boostTerms}, {@code fields}, {@code likeItems}, {@code likeTexts}, {@code maxDocFrequency}, {@code maxQueryTerms}, {@code maxWordLength}, {@code minDocFrequency}, {@code minimumShouldMatch}, {@code minTermFrequency}, {@code minWordLength}, {@code stopWords}, {@code unlikeItems}, {@code unlikeTexts}, {@code failOnUnsupportedField}, {@code include}, {@code boost}, {@code name}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + Objects.hashCode(analyzer); h += (h << 5) + Objects.hashCode(boostTerms); h += (h << 5) + fields.hashCode(); h += (h << 5) + likeItems.hashCode(); h += (h << 5) + likeTexts.hashCode(); h += (h << 5) + Objects.hashCode(maxDocFrequency); h += (h << 5) + Objects.hashCode(maxQueryTerms); h += (h << 5) + Objects.hashCode(maxWordLength); h += (h << 5) + Objects.hashCode(minDocFrequency); h += (h << 5) + Objects.hashCode(minimumShouldMatch); h += (h << 5) + Objects.hashCode(minTermFrequency); h += (h << 5) + Objects.hashCode(minWordLength); h += (h << 5) + stopWords.hashCode(); h += (h << 5) + unlikeItems.hashCode(); h += (h << 5) + unlikeTexts.hashCode(); h += (h << 5) + Objects.hashCode(failOnUnsupportedField); h += (h << 5) + Objects.hashCode(include); h += (h << 5) + Objects.hashCode(boost); h += (h << 5) + Objects.hashCode(name); return h; } /** * Prints the immutable value {@code MoreLikeThisQuery} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("MoreLikeThisQuery") .omitNullValues() .add("analyzer", analyzer) .add("boostTerms", boostTerms) .add("fields", fields) .add("likeItems", likeItems) .add("likeTexts", likeTexts) .add("maxDocFrequency", maxDocFrequency) .add("maxQueryTerms", maxQueryTerms) .add("maxWordLength", maxWordLength) .add("minDocFrequency", minDocFrequency) .add("minimumShouldMatch", minimumShouldMatch) .add("minTermFrequency", minTermFrequency) .add("minWordLength", minWordLength) .add("stopWords", stopWords) .add("unlikeItems", unlikeItems) .add("unlikeTexts", unlikeTexts) .add("failOnUnsupportedField", failOnUnsupportedField) .add("include", include) .add("boost", boost) .add("name", name) .toString(); } @SuppressWarnings("Immutable") private transient volatile long lazyInitBitmap; private static final long LIKE_LAZY_INIT_BIT = 0x1L; @SuppressWarnings("Immutable") private transient List like; /** * {@inheritDoc} *

* Returns a lazily initialized value of the {@link MoreLikeThisQuery#getLike() like} attribute. * Initialized once and only once and stored for subsequent access with proper synchronization. * @return A lazily initialized value of the {@code like} attribute */ @Override public List getLike() { if ((lazyInitBitmap & LIKE_LAZY_INIT_BIT) == 0) { synchronized (this) { if ((lazyInitBitmap & LIKE_LAZY_INIT_BIT) == 0) { this.like = Objects.requireNonNull(MoreLikeThisQuery.super.getLike(), "like"); lazyInitBitmap |= LIKE_LAZY_INIT_BIT; } } } return like; } private static final long UNLIKE_LAZY_INIT_BIT = 0x2L; @SuppressWarnings("Immutable") private transient List unlike; /** * {@inheritDoc} *

* Returns a lazily initialized value of the {@link MoreLikeThisQuery#getUnlike() unlike} attribute. * Initialized once and only once and stored for subsequent access with proper synchronization. * @return A lazily initialized value of the {@code unlike} attribute */ @Override public List getUnlike() { if ((lazyInitBitmap & UNLIKE_LAZY_INIT_BIT) == 0) { synchronized (this) { if ((lazyInitBitmap & UNLIKE_LAZY_INIT_BIT) == 0) { this.unlike = Objects.requireNonNull(MoreLikeThisQuery.super.getUnlike(), "unlike"); lazyInitBitmap |= UNLIKE_LAZY_INIT_BIT; } } } return unlike; } /** * Creates a builder for {@link ImmutableMoreLikeThisQuery ImmutableMoreLikeThisQuery}. * @return A new ImmutableMoreLikeThisQuery builder */ public static ImmutableMoreLikeThisQuery.Builder builder() { return new ImmutableMoreLikeThisQuery.Builder(); } /** * Builds instances of type {@link ImmutableMoreLikeThisQuery ImmutableMoreLikeThisQuery}. * Initialize attributes and then invoke the {@link #build()} method to create an * immutable instance. *

{@code Builder} is not thread-safe and generally should not be stored in a field or collection, * but instead used immediately to create instances. */ @Generated(from = "MoreLikeThisQuery", generator = "Immutables") @NotThreadSafe @JsonTypeName("more_like_this") public static final class Builder { private static final long OPT_BIT_FIELDS = 0x1L; private static final long OPT_BIT_LIKE_ITEMS = 0x2L; private static final long OPT_BIT_LIKE_TEXTS = 0x4L; private static final long OPT_BIT_STOP_WORDS = 0x8L; private static final long OPT_BIT_UNLIKE_ITEMS = 0x10L; private static final long OPT_BIT_UNLIKE_TEXTS = 0x20L; private long optBits; private @javax.annotation.Nullable String analyzer; private @javax.annotation.Nullable Float boostTerms; private ImmutableSet.Builder fields = ImmutableSet.builder(); private ImmutableList.Builder likeItems = ImmutableList.builder(); private ImmutableList.Builder likeTexts = ImmutableList.builder(); private @javax.annotation.Nullable Integer maxDocFrequency; private @javax.annotation.Nullable Integer maxQueryTerms; private @javax.annotation.Nullable Integer maxWordLength; private @javax.annotation.Nullable Integer minDocFrequency; private @javax.annotation.Nullable String minimumShouldMatch; private @javax.annotation.Nullable Integer minTermFrequency; private @javax.annotation.Nullable Integer minWordLength; private ImmutableSet.Builder stopWords = ImmutableSet.builder(); private ImmutableList.Builder unlikeItems = ImmutableList.builder(); private ImmutableList.Builder unlikeTexts = ImmutableList.builder(); private @javax.annotation.Nullable Boolean failOnUnsupportedField; private @javax.annotation.Nullable Boolean include; private @javax.annotation.Nullable Float boost; private @javax.annotation.Nullable String name; private Builder() { } /** * Fill a builder with attribute values from the provided {@code com.arakelian.elastic.model.search.MoreLikeThisQuery} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(MoreLikeThisQuery instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code com.arakelian.elastic.model.search.StandardQuery} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(StandardQuery instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } private void from(Object object) { if (object instanceof MoreLikeThisQuery) { MoreLikeThisQuery instance = (MoreLikeThisQuery) object; addAllLikeItems(instance.getLikeItems()); Integer minDocFrequencyValue = instance.getMinDocFrequency(); if (minDocFrequencyValue != null) { minDocFrequency(minDocFrequencyValue); } Boolean includeValue = instance.isInclude(); if (includeValue != null) { include(includeValue); } Integer maxWordLengthValue = instance.getMaxWordLength(); if (maxWordLengthValue != null) { maxWordLength(maxWordLengthValue); } Integer minTermFrequencyValue = instance.getMinTermFrequency(); if (minTermFrequencyValue != null) { minTermFrequency(minTermFrequencyValue); } Boolean failOnUnsupportedFieldValue = instance.isFailOnUnsupportedField(); if (failOnUnsupportedFieldValue != null) { failOnUnsupportedField(failOnUnsupportedFieldValue); } addAllUnlikeTexts(instance.getUnlikeTexts()); addAllUnlikeItems(instance.getUnlikeItems()); Integer maxDocFrequencyValue = instance.getMaxDocFrequency(); if (maxDocFrequencyValue != null) { maxDocFrequency(maxDocFrequencyValue); } String minimumShouldMatchValue = instance.getMinimumShouldMatch(); if (minimumShouldMatchValue != null) { minimumShouldMatch(minimumShouldMatchValue); } addAllStopWords(instance.getStopWords()); addAllLikeTexts(instance.getLikeTexts()); Integer maxQueryTermsValue = instance.getMaxQueryTerms(); if (maxQueryTermsValue != null) { maxQueryTerms(maxQueryTermsValue); } String analyzerValue = instance.getAnalyzer(); if (analyzerValue != null) { analyzer(analyzerValue); } Integer minWordLengthValue = instance.getMinWordLength(); if (minWordLengthValue != null) { minWordLength(minWordLengthValue); } addAllFields(instance.getFields()); Float boostTermsValue = instance.getBoostTerms(); if (boostTermsValue != null) { boostTerms(boostTermsValue); } } if (object instanceof StandardQuery) { StandardQuery instance = (StandardQuery) object; String nameValue = instance.getName(); if (nameValue != null) { name(nameValue); } Float boostValue = instance.getBoost(); if (boostValue != null) { boost(boostValue); } } } /** * Initializes the value for the {@link MoreLikeThisQuery#getAnalyzer() analyzer} attribute. * @param analyzer The value for analyzer (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("analyzer") public final Builder analyzer(@Nullable String analyzer) { this.analyzer = analyzer; return this; } /** * Initializes the value for the {@link MoreLikeThisQuery#getBoostTerms() boostTerms} attribute. * @param boostTerms The value for boostTerms (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("boost_terms") public final Builder boostTerms(@Nullable Float boostTerms) { this.boostTerms = boostTerms; return this; } /** * Adds one element to {@link MoreLikeThisQuery#getFields() fields} set. * @param element A fields element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addField(String element) { this.fields.add(element); optBits |= OPT_BIT_FIELDS; return this; } /** * Adds elements to {@link MoreLikeThisQuery#getFields() fields} set. * @param elements An array of fields elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addFields(String... elements) { this.fields.add(elements); optBits |= OPT_BIT_FIELDS; return this; } /** * Sets or replaces all elements for {@link MoreLikeThisQuery#getFields() fields} set. * @param elements An iterable of fields elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("fields") public final Builder fields(Iterable elements) { this.fields = ImmutableSet.builder(); return addAllFields(elements); } /** * Adds elements to {@link MoreLikeThisQuery#getFields() fields} set. * @param elements An iterable of fields elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllFields(Iterable elements) { this.fields.addAll(elements); optBits |= OPT_BIT_FIELDS; return this; } /** * Adds one element to {@link MoreLikeThisQuery#getLikeItems() likeItems} list. * @param element A likeItems element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addLikeItem(MoreLikeThisQuery.Item element) { this.likeItems.add(element); optBits |= OPT_BIT_LIKE_ITEMS; return this; } /** * Adds elements to {@link MoreLikeThisQuery#getLikeItems() likeItems} list. * @param elements An array of likeItems elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addLikeItems(MoreLikeThisQuery.Item... elements) { this.likeItems.add(elements); optBits |= OPT_BIT_LIKE_ITEMS; return this; } /** * Sets or replaces all elements for {@link MoreLikeThisQuery#getLikeItems() likeItems} list. * @param elements An iterable of likeItems elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("like_items") public final Builder likeItems(Iterable elements) { this.likeItems = ImmutableList.builder(); return addAllLikeItems(elements); } /** * Adds elements to {@link MoreLikeThisQuery#getLikeItems() likeItems} list. * @param elements An iterable of likeItems elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllLikeItems(Iterable elements) { this.likeItems.addAll(elements); optBits |= OPT_BIT_LIKE_ITEMS; return this; } /** * Adds one element to {@link MoreLikeThisQuery#getLikeTexts() likeTexts} list. * @param element A likeTexts element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addLikeText(String element) { this.likeTexts.add(element); optBits |= OPT_BIT_LIKE_TEXTS; return this; } /** * Adds elements to {@link MoreLikeThisQuery#getLikeTexts() likeTexts} list. * @param elements An array of likeTexts elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addLikeTexts(String... elements) { this.likeTexts.add(elements); optBits |= OPT_BIT_LIKE_TEXTS; return this; } /** * Sets or replaces all elements for {@link MoreLikeThisQuery#getLikeTexts() likeTexts} list. * @param elements An iterable of likeTexts elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("like_texts") public final Builder likeTexts(Iterable elements) { this.likeTexts = ImmutableList.builder(); return addAllLikeTexts(elements); } /** * Adds elements to {@link MoreLikeThisQuery#getLikeTexts() likeTexts} list. * @param elements An iterable of likeTexts elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllLikeTexts(Iterable elements) { this.likeTexts.addAll(elements); optBits |= OPT_BIT_LIKE_TEXTS; return this; } /** * Initializes the value for the {@link MoreLikeThisQuery#getMaxDocFrequency() maxDocFrequency} attribute. * @param maxDocFrequency The value for maxDocFrequency (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("max_doc_freq") public final Builder maxDocFrequency(@Nullable Integer maxDocFrequency) { this.maxDocFrequency = maxDocFrequency; return this; } /** * Initializes the value for the {@link MoreLikeThisQuery#getMaxQueryTerms() maxQueryTerms} attribute. * @param maxQueryTerms The value for maxQueryTerms (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("max_query_terms") public final Builder maxQueryTerms(@Nullable Integer maxQueryTerms) { this.maxQueryTerms = maxQueryTerms; return this; } /** * Initializes the value for the {@link MoreLikeThisQuery#getMaxWordLength() maxWordLength} attribute. * @param maxWordLength The value for maxWordLength (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("max_word_length") public final Builder maxWordLength(@Nullable Integer maxWordLength) { this.maxWordLength = maxWordLength; return this; } /** * Initializes the value for the {@link MoreLikeThisQuery#getMinDocFrequency() minDocFrequency} attribute. * @param minDocFrequency The value for minDocFrequency (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("min_doc_freq") public final Builder minDocFrequency(@Nullable Integer minDocFrequency) { this.minDocFrequency = minDocFrequency; return this; } /** * Initializes the value for the {@link MoreLikeThisQuery#getMinimumShouldMatch() minimumShouldMatch} attribute. * @param minimumShouldMatch The value for minimumShouldMatch (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("minimum_should_match") public final Builder minimumShouldMatch(@Nullable String minimumShouldMatch) { this.minimumShouldMatch = minimumShouldMatch; return this; } /** * Initializes the value for the {@link MoreLikeThisQuery#getMinTermFrequency() minTermFrequency} attribute. * @param minTermFrequency The value for minTermFrequency (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("min_term_freq") public final Builder minTermFrequency(@Nullable Integer minTermFrequency) { this.minTermFrequency = minTermFrequency; return this; } /** * Initializes the value for the {@link MoreLikeThisQuery#getMinWordLength() minWordLength} attribute. * @param minWordLength The value for minWordLength (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("min_word_length") public final Builder minWordLength(@Nullable Integer minWordLength) { this.minWordLength = minWordLength; return this; } /** * Adds one element to {@link MoreLikeThisQuery#getStopWords() stopWords} set. * @param element A stopWords element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addStopWord(String element) { this.stopWords.add(element); optBits |= OPT_BIT_STOP_WORDS; return this; } /** * Adds elements to {@link MoreLikeThisQuery#getStopWords() stopWords} set. * @param elements An array of stopWords elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addStopWords(String... elements) { this.stopWords.add(elements); optBits |= OPT_BIT_STOP_WORDS; return this; } /** * Sets or replaces all elements for {@link MoreLikeThisQuery#getStopWords() stopWords} set. * @param elements An iterable of stopWords elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("stop_words") public final Builder stopWords(Iterable elements) { this.stopWords = ImmutableSet.builder(); return addAllStopWords(elements); } /** * Adds elements to {@link MoreLikeThisQuery#getStopWords() stopWords} set. * @param elements An iterable of stopWords elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllStopWords(Iterable elements) { this.stopWords.addAll(elements); optBits |= OPT_BIT_STOP_WORDS; return this; } /** * Adds one element to {@link MoreLikeThisQuery#getUnlikeItems() unlikeItems} list. * @param element A unlikeItems element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addUnlikeItem(MoreLikeThisQuery.Item element) { this.unlikeItems.add(element); optBits |= OPT_BIT_UNLIKE_ITEMS; return this; } /** * Adds elements to {@link MoreLikeThisQuery#getUnlikeItems() unlikeItems} list. * @param elements An array of unlikeItems elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addUnlikeItems(MoreLikeThisQuery.Item... elements) { this.unlikeItems.add(elements); optBits |= OPT_BIT_UNLIKE_ITEMS; return this; } /** * Sets or replaces all elements for {@link MoreLikeThisQuery#getUnlikeItems() unlikeItems} list. * @param elements An iterable of unlikeItems elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("unlike_items") public final Builder unlikeItems(Iterable elements) { this.unlikeItems = ImmutableList.builder(); return addAllUnlikeItems(elements); } /** * Adds elements to {@link MoreLikeThisQuery#getUnlikeItems() unlikeItems} list. * @param elements An iterable of unlikeItems elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllUnlikeItems(Iterable elements) { this.unlikeItems.addAll(elements); optBits |= OPT_BIT_UNLIKE_ITEMS; return this; } /** * Adds one element to {@link MoreLikeThisQuery#getUnlikeTexts() unlikeTexts} list. * @param element A unlikeTexts element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addUnlikeText(String element) { this.unlikeTexts.add(element); optBits |= OPT_BIT_UNLIKE_TEXTS; return this; } /** * Adds elements to {@link MoreLikeThisQuery#getUnlikeTexts() unlikeTexts} list. * @param elements An array of unlikeTexts elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addUnlikeTexts(String... elements) { this.unlikeTexts.add(elements); optBits |= OPT_BIT_UNLIKE_TEXTS; return this; } /** * Sets or replaces all elements for {@link MoreLikeThisQuery#getUnlikeTexts() unlikeTexts} list. * @param elements An iterable of unlikeTexts elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("unlike_texts") public final Builder unlikeTexts(Iterable elements) { this.unlikeTexts = ImmutableList.builder(); return addAllUnlikeTexts(elements); } /** * Adds elements to {@link MoreLikeThisQuery#getUnlikeTexts() unlikeTexts} list. * @param elements An iterable of unlikeTexts elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllUnlikeTexts(Iterable elements) { this.unlikeTexts.addAll(elements); optBits |= OPT_BIT_UNLIKE_TEXTS; return this; } /** * Initializes the value for the {@link MoreLikeThisQuery#isFailOnUnsupportedField() failOnUnsupportedField} attribute. * @param failOnUnsupportedField The value for failOnUnsupportedField (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("fail_on_unsupported_field") public final Builder failOnUnsupportedField(@Nullable Boolean failOnUnsupportedField) { this.failOnUnsupportedField = failOnUnsupportedField; return this; } /** * Initializes the value for the {@link MoreLikeThisQuery#isInclude() include} attribute. * @param include The value for include (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("include") public final Builder include(@Nullable Boolean include) { this.include = include; return this; } /** * Initializes the value for the {@link MoreLikeThisQuery#getBoost() boost} attribute. * @param boost The value for boost (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("boost") public final Builder boost(@Nullable Float boost) { this.boost = boost; return this; } /** * Initializes the value for the {@link MoreLikeThisQuery#getName() name} attribute. * @param name The value for name (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("_name") public final Builder name(@Nullable String name) { this.name = name; return this; } /** * Builds a new {@link ImmutableMoreLikeThisQuery ImmutableMoreLikeThisQuery}. * @return An immutable instance of MoreLikeThisQuery * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableMoreLikeThisQuery build() { return new ImmutableMoreLikeThisQuery(this); } private boolean fieldsIsSet() { return (optBits & OPT_BIT_FIELDS) != 0; } private boolean likeItemsIsSet() { return (optBits & OPT_BIT_LIKE_ITEMS) != 0; } private boolean likeTextsIsSet() { return (optBits & OPT_BIT_LIKE_TEXTS) != 0; } private boolean stopWordsIsSet() { return (optBits & OPT_BIT_STOP_WORDS) != 0; } private boolean unlikeItemsIsSet() { return (optBits & OPT_BIT_UNLIKE_ITEMS) != 0; } private boolean unlikeTextsIsSet() { return (optBits & OPT_BIT_UNLIKE_TEXTS) != 0; } } }