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

com.github.wz2cool.elasticsearch.query.builder.TermExtQueryBuilder Maven / Gradle / Ivy

There is a newer version: 0.1.6
Show newest version
package com.github.wz2cool.elasticsearch.query.builder;

import com.github.wz2cool.elasticsearch.lambda.GetArrayPropertyFunction;
import com.github.wz2cool.elasticsearch.lambda.GetPropertyFunction;
import com.github.wz2cool.elasticsearch.model.ColumnInfo;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.TermQueryBuilder;

/**
 * A Query that matches documents containing a term.
 *
 * @author Frank
 */
public class TermExtQueryBuilder implements ExtQueryBuilder {

    private final TermQueryBuilder termQueryBuilder;

    /**
     * @see TermQueryBuilder#TermQueryBuilder(String, Object)
     */
    public TermExtQueryBuilder(GetPropertyFunction getPropertyFunc, P value) {
        final ColumnInfo columnInfo = getColumnInfo(getPropertyFunc);
        this.termQueryBuilder = new TermQueryBuilder(columnInfo.getColumnName(), getFilterValue(value));
    }

    /**
     * @see TermQueryBuilder#TermQueryBuilder(String, Object)
     */
    public TermExtQueryBuilder(GetArrayPropertyFunction getPropertyFunc, P value) {
        final ColumnInfo columnInfo = getColumnInfo(getPropertyFunc);
        this.termQueryBuilder = new TermQueryBuilder(columnInfo.getColumnName(), getFilterValue(value));
    }

    @Override
    public QueryBuilder build() {
        return this.termQueryBuilder;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy