Exemple #1
0
        // TODO: Enough of those ifs, create IRequestComponent or smth
        public object BuildRequestObject()
        {
            ExpandoObject requestObject = new ExpandoObject();

            ExpandoObject querySection = BuildQuerySection();

            if (querySection != null && Query != null)
            {
                throw new InvalidOperationException("Simple QUERY must be alone, it can't work with INDICES or FILTERED");
            }
            if (Query != null)
            {
                requestObject.Add("query", Query.BuildRequestComponent());
            }
            requestObject.AddIfNotNull("query", querySection);

            requestObject.AddIfNotNull("aggs", Aggregates.BuildRequestComponent());
            requestObject.AddIfNotNull("size", Size);

            if (Sort.Count != 0)
            {
                requestObject.Add("sort", Sort);
            }

            return(requestObject);
        }
        public ExpandoObject BuildRequestComponent()
        {
            ExpandoObject groupAggregateComponent = _groupByAggregate.BuildRequestComponent();

            groupAggregateComponent.AddIfNotNull("aggs", Aggregates.BuildRequestComponent());

            return(groupAggregateComponent);
        }