+1 800 256 3608 (toll-free in North America) or +49 7531 90 60 10| service@combit.com

Connecting List & Label to Elasticsearch Using NEST in C#


NEST is a convenient way to access Elasticsearch data. List & Label can easily be bound to NEST result objects, which enables to bind to data from Elasticsearch clusters.


As the response object is rather complex, you should set a couple of properties on an explicitly generated ObjectDataProvider object in order to present the user with just what is required. A minimal example (using the data from this example) might be:

using (ListLabel LL = new ListLabel())
    // retrieve data from Elasticsearch
    var response = ConnectionToES.EsClient().Search<DocumentAttributes>(s => s
    .Query(q => q.MatchAll()));

    // create ObjectDataProvider with minimal clutter
    ObjectDataProvider provider = new ObjectDataProvider(response.Hits)
        // flatten structure to the minimal amount required
        MaximumRecursionDepth = 1,

        // assign a nice, descriptive name to the main data table
        RootTableName = "Data"

    // register event of the ObjectDataProvider to engage into its parsing
    provider.HandleEnumerableProperty += Provider_HandleEnumerableProperty;

    // bind to data and call the Designer
    LL.DataSource = provider;

Using the event HandleEnumerableProperty of the List & Label ObjectDataProvider provides access to the assigned object structure:

private void Provider_HandleEnumerableProperty(object sender, HandleEnumerablePropertyEventArgs e)
    // just don't follow any paths
    e.CancelRecursion = true;


The data is then available from the Data > Source folder in the Designer:


and can easily be used from there as simple table:


If you want to further strip this down, you may create a simplified, typed object from the results of course as well.

© combit GmbH