com.arakelian.elastic.model.search.MoreLikeThisQuery Maven / Gradle / Ivy
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arakelian.elastic.model.search;
import java.util.List;
import java.util.Set;
import org.immutables.value.Value;
import com.arakelian.core.feature.Nullable;
import com.arakelian.elastic.search.QueryVisitor;
import com.arakelian.jackson.MapPath;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
/**
* @see More
* Like This Query
*/
@Value.Immutable(copy = false)
@JsonSerialize(as = ImmutableMoreLikeThisQuery.class)
@JsonDeserialize(builder = ImmutableMoreLikeThisQuery.Builder.class)
@JsonTypeName(Query.MORE_LIKE_THIS_QUERY)
public interface MoreLikeThisQuery extends StandardQuery {
@Value.Immutable(copy = false)
@JsonSerialize(as = ImmutableItem.class)
@JsonDeserialize(builder = ImmutableItem.Builder.class)
@JsonPropertyOrder({ "_index", "_type", "_id", "doc" })
public interface Item {
@Value.Check
public default void checkItem() {
Preconditions.checkState(
getId() == null && getDoc() != null || getId() != null && getDoc() == null,
"id or doc may be specified, but not both");
}
@Nullable
@JsonProperty("doc")
public MapPath getDoc();
@Nullable
@JsonProperty("_id")
public String getId();
@Nullable
@JsonProperty("_index")
public String getIndex();
@Nullable
@JsonProperty("_type")
public String getType();
}
@Override
default void accept(final QueryVisitor visitor) {
if (!visitor.enter(this)) {
return;
}
try {
if (visitor.enterMoreLikeThisQuery(this)) {
visitor.leaveMoreLikeThisQuery(this);
}
} finally {
visitor.leave(this);
}
}
/**
* 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
*/
@Nullable
@JsonProperty("analyzer")
public String getAnalyzer();
/**
* 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
*/
@Nullable
@JsonProperty("boost_terms")
public Float getBoostTerms();
@Value.Default
@JsonProperty("fields")
public default Set getFields() {
return ImmutableSet.of();
}
@JsonIgnore
@Value.Lazy
public default List © 2015 - 2025 Weber Informatics LLC | Privacy Policy