Skip to content

Instantly share code, notes, and snippets.

Last active Aug 19, 2018
What would you like to do?
The Controller Endpoint for using a Kendo Grid against ElasticSearch
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Nest;
public class GridController : Controller
private readonly ElasticClient _elasticClient;
public GridController()
//Initalize ElasticClient
public async Task<IActionResult> PostRequest([FromBody]RequestDto request)
CompositeFilterMapper compositeFilterMapper = new CompositeFilterMapper();
//Grab a page from elastic
selector = search =>
.Query(q =>
var searchResponse = _elasticClient.Search(selector);
return Ok(new ResponseDto
Results = searchResponse.Documents,
Count = searchResponse.Total
public class ResponseDto<T>
public IEnumerable<T> Results { get; set; }
public long Count { get; set; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment