- /**
- * The list of queries to be applied to the document store.
- */
- private Query[] queries;
-
- /**
- * The list of aggregations to be applied to the search
- */
- private Aggregation[] aggregations;
-
- /**
- * Defines the sort criteria to apply to the query result set.
- * This is optional.
- */
- private Sort sort;
-
- @JsonProperty("results-start")
- private Integer resultsStart;
-
- @JsonProperty("results-size")
- private Integer size;
-
- public Filter getFilter() {
- return filter;
- }
-
- public void setFilter(Filter filter) {
- this.filter = filter;
- }
-
- public Query[] getQueries() {
- return queries;
- }
-
- public void setQueries(Query[] queries) {
- this.queries = queries;
- }
-
- public Sort getSort() {
- return sort;
- }
-
- public void setSort(Sort sort) {
- this.sort = sort;
- }
-
- public boolean isFiltered() {
- return filter != null;
- }
-
- public Aggregation[] getAggregations() {
- return aggregations;
- }
-
- public void setAggregations(Aggregation[] aggregations) {
- this.aggregations = aggregations;
- }
-
- public boolean hasAggregations() {
- return aggregations != null && aggregations.length > 0;
- }
-
- public Integer getFrom() {
- return resultsStart;
- }
-
- public void setFrom(Integer from) {
- this.resultsStart = from;
- }
-
- public Integer getSize() {
- return size;
- }
-
- public void setSize(Integer size) {
- this.size = size;
- }
-
- /**
- * This method returns a string which represents this statement in syntax
- * that is understandable by ElasticSearch and is suitable for inclusion
- * in an ElasticSearch query string.
- *
- * @return - ElasticSearch syntax string.
- */
- public String toElasticSearch() {
-
- StringBuilder sb = new StringBuilder();
- List<QueryStatement> notMatchQueries = new ArrayList<QueryStatement>();
- List<QueryStatement> mustQueries = new ArrayList<QueryStatement>();
- List<QueryStatement> shouldQueries = new ArrayList<QueryStatement>();
-
- createQueryLists(queries, mustQueries, shouldQueries, notMatchQueries);
-
- sb.append("{");
-
- sb.append("\"version\": true,");
-
- // If the client has specified an index into the results for the first
- // document in the result set then include that in the ElasticSearch
- // query.
- if (resultsStart != null) {
- sb.append("\"from\": ").append(resultsStart).append(", ");
- }