com.scaleset.search.Query Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scaleset-search Show documentation
Show all versions of scaleset-search Show documentation
Java object model for representing query requests in REST protocols.
package com.scaleset.search;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.vividsolutions.jts.geom.Envelope;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@JsonInclude(Include.NON_EMPTY)
public class Query {
private HashMap aggs = new HashMap<>();
private Envelope bbox;
private Map filters = new HashMap<>();
private String[] fields;
private String geoField;
private int limit;
private int offset = 0;
private Map headers = new HashMap<>();
private String q;
private Sort[] sorts;
/* For Jackson */
public Query() {
}
public Query(String q, Envelope bbox, String geoField, List fields, int offset, int limit, List sorts, Map aggs, Map filters, Map headers) {
this.q = q;
this.offset = offset;
this.limit = limit;
this.bbox = bbox;
this.geoField = geoField;
this.fields = fields.toArray(new String[fields.size()]);
this.sorts = sorts.toArray(new Sort[sorts.size()]);
if (aggs != null) {
for (String name : aggs.keySet()) {
Aggregation agg = aggs.get(name);
this.aggs.put(name, new Aggregation(name, agg.getType(), agg.anyGetter(), agg.getAggs()));
}
}
if (filters != null) {
for (String name : filters.keySet()) {
Filter filter = filters.get(name);
this.filters.put(name, new Filter(name, filter.getType(), filter.anyGetter()));
}
this.filters.putAll(filters);
}
if (headers != null) {
this.headers.putAll(headers);
}
}
public Map getAggs() {
return aggs;
}
public Envelope getBbox() {
return bbox;
}
public Map getFilters() {
return filters;
}
public String getGeoField() {
return geoField;
}
public int getLimit() {
return limit;
}
public int getOffset() {
return offset;
}
public Map getHeaders() {
return headers;
}
public String getQ() {
return q;
}
public Sort[] getSorts() {
return sorts;
}
public String[] getFields() {
return fields;
}
}