RangeQuery.java 846 Bytes
package com.zhaoonline.common.es.bean;

import org.elasticsearch.index.query.QueryBuilders;

public class RangeQuery implements QueryInt {
	
	private Object from;
	private Object to;
	private String rangeKey;
	
	public RangeQuery(String rangeKey,Object from,Object to){
		this.rangeKey=rangeKey;
		this.from=from;
		this.to=to;
	}

	public Object getFrom() {
		return from;
	}

	public void setFrom(Object from) {
		this.from = from;
	}

	public Object getTo() {
		return to;
	}

	public void setTo(Object to) {
		this.to = to;
	}

	public String getRangeKey() {
		return rangeKey;
	}

	public void setRangeKey(String rangeKey) {
		this.rangeKey = rangeKey;
	}

	@Override
	public String getType() {
		return "range";
	}

	@Override
	public String toQueryString() {
		return QueryBuilders.rangeQuery(rangeKey).from(from).to(to).toString();
	}

}