Reputation: 35
I´m doing a paging query with a simple filter, it´s working like a charm.
var result = client.Search<MyMetaData>(
x => x.Index("MyIndex")
.Type("MyType")
.QueryString(filtro)
.From(from)
.Size(size)
);
But I need to know the number of results without paging to inform users.
I´m trying to do with the Count
method, but without success.
Upvotes: 1
Views: 1203
Reputation: 12439
In ES you can use the "Size" field to limit the number of records returned but the "Total" field will always have the correct total on the server even if only 100 records are returned (as with my sample below).
var result = ElasticClient.Search<PackingConfigES>(x =>
x.Size(100)
.MatchAll()
);
var totalResults = result.Total;
Upvotes: 3