com.github.wz2cool.elasticsearch.query.builder.RangeExtQueryBuilder Maven / Gradle / Ivy
package com.github.wz2cool.elasticsearch.query.builder;
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.RangeQueryBuilder;
/**
* A Query that matches documents within an range of terms.
*
* @author Frank
*/
public class RangeExtQueryBuilder implements ExtQueryBuilder {
private final RangeQueryBuilder rangeQueryBuilder;
/**
* @see RangeQueryBuilder#RangeQueryBuilder(String)
*/
public RangeExtQueryBuilder(GetPropertyFunction getPropertyFunc) {
final ColumnInfo columnInfo = getColumnInfo(getPropertyFunc);
this.rangeQueryBuilder = new RangeQueryBuilder(columnInfo.getColumnName());
}
/**
* @see RangeQueryBuilder#gt(Object)
*/
public RangeExtQueryBuilder gt(boolean enable, P from) {
if (enable) {
rangeQueryBuilder.gt(getFilterValue(from));
}
return this;
}
/**
* @see RangeQueryBuilder#gt(Object)
*/
public RangeExtQueryBuilder gt(P from) {
rangeQueryBuilder.gt(getFilterValue(from));
return this;
}
/**
* @see RangeQueryBuilder#gte(Object)
*/
public RangeExtQueryBuilder gte(boolean enable, P from) {
if (enable) {
rangeQueryBuilder.gte(getFilterValue(from));
}
return this;
}
/**
* @see RangeQueryBuilder#gte(Object)
*/
public RangeExtQueryBuilder gte(P from) {
rangeQueryBuilder.gte(getFilterValue(from));
return this;
}
/**
* @see RangeQueryBuilder#lt(Object)
*/
public RangeExtQueryBuilder lt(boolean enable, P to) {
if (enable) {
rangeQueryBuilder.lt(getFilterValue(to));
}
return this;
}
/**
* @see RangeQueryBuilder#lt(Object)
*/
public RangeExtQueryBuilder lt(P to) {
rangeQueryBuilder.lt(getFilterValue(to));
return this;
}
/**
* @see RangeQueryBuilder#lte(Object)
*/
public RangeExtQueryBuilder lte(boolean enable, P to) {
if (enable) {
rangeQueryBuilder.lte(getFilterValue(to));
}
return this;
}
/**
* @see RangeQueryBuilder#lte(Object)
*/
public RangeExtQueryBuilder lte(P to) {
rangeQueryBuilder.lte(getFilterValue(to));
return this;
}
/**
* @see RangeQueryBuilder#timeZone(String)
*/
public RangeExtQueryBuilder timezone(String timeZone) {
rangeQueryBuilder.timeZone(timeZone);
return this;
}
/**
* @see RangeQueryBuilder#relation(String)
*/
public RangeExtQueryBuilder relation(String relation) {
rangeQueryBuilder.relation(relation);
return this;
}
@Override
public QueryBuilder build() {
return this.rangeQueryBuilder;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy