From / Sizeedit

Pagination can be done using From() and Size():




can also be used.

Indices / Typesedit

NEST will automatically infer the index to search based on the type specified:

client.Search<MyObject>(s => s

If MyObject has not been mapped to an index, then the default index will be used.

You can override type inferrence by explicitly specifying the index to search on:

client.Search<MyObject>(s => s

Remember that since Elasticsearch 0.19.8 you can also specify wildcards on index names:

client.Search<MyObject>(s => s
.Types(new [] { typeof(ElasticSearchProject)})

You can also tell NEST to search multiple indices:

client.Search<MyObject>(s => s
    .Indices(new [] {"Index_A", "Index_B"})

Or you can search across all indices

client.Search<MyObject>(s => s


You can make C# covariance work for you by typing the search to a common base class (can be object)


.Search<object>(s => s
    .Types(typeof(Product), typeof(Category), typeof(Manufacturer))
    .Query(q => ...)

This will search on /yourdefaultindex/products,categories,manufacturers/_search and setup a default ConcreteTypeSelector that understands what type each returned document is.


.ConcreteTypeSelector(Func<dynamic, Hit<dynamic>, Type>)

you can manually specify the type of each hit based on some JSON value (on dynamic) or on the hit metadata.


You can specify the routing for the search request using