Reputation: 426
Can someone point me in the right direction of how to implement this?
So far I can query my index and get a response
SearchIndexClient indexClient = service.Indexes.GetClient(indexName);
SearchParameters sp = new SearchParameters()
{
Facets = new string[] { "Brand", "Price,values:10|25|100|500|1000|2500" },
Filter = AzureUtils.BuildFilter(brand, priceFrom, priceTo),
OrderBy = new string[] { "" },
IncludeTotalResultCount = true,
Top = 9,
SearchMode = SearchMode.Any
};
DocumentSearchResponse<MyClass> response = response = indexClient.Documents.Search<MyClass>(searchText, sp);
When the result comes back the response.ContinuationToken is null
How can I get my index to return a value for the response.ContinuationToken property.
Also, how do I can implement this to fetch the next 9 results?
Thanks
Upvotes: 9
Views: 3864
Reputation: 8634
TL;DR version: The safest assumption is that the presence or absence of a continuation token in a search response is completely out of your control.
The SearchContinuationToken
is not meant for paging of results. That's what SearchParameters.Top
and SearchParameters.Skip
are for. Instead, you can think of the continuation token as a mechanism to resume a search that couldn't be completed in a single request for potentially arbitrary reasons. The docs on MSDN mention page size as the reason, but this should not be understood to be part of the contract of ContinueSearch
. In principle there could be other reasons why Azure Search hands back a continuation token. No matter the reason, if you want to write a robust client you should be prepared to handle continuation tokens, regardless of Top
, your result count, or any other factor.
Upvotes: 10
Reputation: 426
I found my answer here - Link
This property will be null unless you request more results than the page size. This can happen either when you do not specify Top and there are more than 50 results (default page size is 50), or when you specify a value greater than 1000 for Top and there are more than 1000 results (maximum page size is 1000). In either case, you can pass the value of this property to the ContinueSearchAsync method to retrieve the next page of results.
I hope that it helps someone else if they get stuck like me
Upvotes: 10