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

sirius.search.constraints.Unscored Maven / Gradle / Ivy

Go to download

Provides a thin layer above Elasticsearch (Fluent Query API, Automatic Mapping, Utilities)

The newest version!
/*
 * Made with all the love in the world
 * by scireum in Remshalden, Germany
 *
 * Copyright by scireum GmbH
 * http://www.scireum.de - [email protected]
 */

package sirius.search.constraints;

import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;

/**
 * Represents a constraint which marks the wrapped constraint so that it is not considered during score calculation.
 */
public class Unscored implements Constraint {

    private Constraint constraint;

    /**
     * Creates a new constraint which excludes {@link #constraint} from scoring.
     *
     * @param constraint the constraint that shoulde be excluded from scoring
     * @return a new constraint representing an unscored constraint
     */
    public static Unscored of(Constraint constraint) {
        Unscored unscored = new Unscored();
        unscored.constraint = constraint;
        return unscored;
    }

    @Override
    public QueryBuilder createQuery() {
        return QueryBuilders.boolQuery().filter(constraint.createQuery());
    }

    @Override
    public String toString(boolean skipConstraintValues) {
        return "Unscored ( " + constraint.toString(skipConstraintValues) + " )";
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy