// 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); }
internal ExpandoObject BuildIndicesSection() { if (IndcesItems.Count == 0 && _query == null && _notQuery == null) { return(null); } if (IndcesItems.Count > 0 && _query == null) { Debug.WriteLine("WARNING: Query might fail: If at least one Indice is provided, MatchingQuery must be defined too!"); } ExpandoObject indicesObject = new ExpandoObject(); if (IndcesItems.Count != 0) { indicesObject.Add("indices", IndcesItems); } indicesObject.AddIfNotNull("query", (_query == null ? null : _query.BuildRequestComponent())); indicesObject.AddIfNotNull("no_match_query", (_notQuery == null ? null : _notQuery.BuildRequestComponent())); return(indicesObject); }