public async Task <IEnumerable <ProductModel> > GetAll(PaginationModel paginationModel) { var search = await context.SearchAsync <ProductModel>(x => x .From(paginationModel.Offset) .Size(paginationModel.PageSize) .Query(q => q.MatchAll()) .Index(context.GetIndexName <ProductModel>())); return(search.Documents); }
public async Task <IEnumerable <ProductModel> > GetAll(int userId, PaginationModel paginationModel) { var search = await context.SearchAsync <WishModel>(x => x .Query(q => q.Term(f => f.Field("_id").Value(userId))) .Index(context.GetIndexName <WishModel>())); return(search.Documents.Any() ? search.Documents.First().Products .Skip(paginationModel.Offset) .Take(paginationModel.PageSize) .OrderBy(x => x.Id) : Enumerable.Empty <ProductModel>()); }
public ProductModelIndexMapping(IndexContext context) { context.Indices.Create(context.GetIndexName <ProductModel>(), c => c .Map <ProductModel>(m => m .Properties(p => p .Number(nm => nm.Name(n => n.Id).Type(NumberType.Integer)) .Text(tx => tx.Name(n => n.Name).Analyzer("keyword")) ) )); }
public WishModelIndexMapping(IndexContext context) { context.Indices.Create(context.GetIndexName <WishModel>(), c => c .Map <WishModel>(m => m .Properties(p => p .Number(nm => nm.Name(n => n.Id)) .Nested <ProductModel>(nt => nt.Name(n => n.Products)) ) ) ); }