- .Index("onoff-products-tests-main")
- .RequestCache(true)
- .From(0)
- .Size(15)
- .Query(q =>
- {
- QueryContainer container = +q.Terms(c => c
- .Field("categories.id")
- .Terms(categoryIds));
- if (manufacturerIds?.Any() == true)
- { container = container && +q.Terms(ma => ma .Field("manufacturers.id") .Terms(manufacturerIds));
- }
- if (filteredSpecs?.Any() == true)
- { container = container && +q.Terms(ma => ma .Field("options.id") .Terms(filteredSpecs));
- }
- if (vendorIds?.Any() == true)
- { container = container && +q.Terms(c => c .Field("vendor.id") .Terms(vendorIds));
- }
- if (inStorage == true)
- { container = container && +q.Term(c => c .Field("inStorage") .Value(true));
- }
- if (priceMax.HasValue || priceMin.HasValue)
- { container = container && +q.TermRange(x => x .Field("price") .GreaterThan("0") .LessThan("20"));
- } return container;
- }).Aggregations(agg => agg .Terms("products_aggregation", x => x.Field("modelName.keyword")
- .Include(partition,partition+15)
- .Size(15)
- .Aggregations(agg2 => agg2
- .TopHits("sameModeledProducts_aggregation", s => s.Sort((ss) =>
- { switch (orderBy)
- { case ProductSortingEnum.NameAsc:
- return ss.Ascending(ff => ff.Name);
- case ProductSortingEnum.NameDesc:
- return ss.Descending(ff => ff.Name);
- case ProductSortingEnum.PriceAsc:
- return ss.Ascending(ff => ff.Price);
- case ProductSortingEnum.PriceDesc:
- return ss.Descending(ff => ff.Price);
- case ProductSortingEnum.MostViewedDesc:
- return ss.Descending(ff => ff.Price);
- default: return ss.Descending(ff => ff.Price); } })
- .Source(ss => ss.Includes(i => i.Field(f => f.Id))) .Size(100)))));
I need to have pagination here plus sorting on parent aggregation and sub aggregation but i dont know what to do pls help me to change this original...