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
Create a search service in the Azure portal. Start with Import data wizard. Choose a built-in sample or a supported data source to create, load, and query an index in minutes. Finish with Search Explorer, using a portal client to query the search index you just created.
Under Settings on the left navigation pane, select Networking. On the Shared Private Access tab, select + Add Shared Private Access. On the blade that opens on the right, select either Connect to an Azure resource in my directory or Connect to an Azure resource by resource ID or alias.
Query using Search explorer The tool supports simple query syntax and full Lucene query parser. Select Search explorer on the command bar. From Index, choose "hotels-sample-index". In the search bar, paste in a query string from the examples below and select Search.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With