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

sirius.search.constraints.NotFilled 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 verifies that a given field is empty.
 */
public class NotFilled implements Constraint {

    private String field;

    /*
     * Use the #on(String) factory method
     */
    private NotFilled(String field) {
        this.field = field;
    }

    /**
     * Creates a new constraint which verifies that the given field is empty.
     *
     * @param field to field to be checked
     * @return the newly created constraint
     */
    public static Constraint on(String field) {
        return new NotFilled(field);
    }

    @Override
    public QueryBuilder createQuery() {
        return QueryBuilders.boolQuery().mustNot(QueryBuilders.existsQuery(field));
    }

    @Override
    public String toString() {
        return toString(false);
    }

    @Override
    public String toString(boolean skipConstraintValues) {
        return field + " IS NULL";
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy