This repository was archived by the owner on Feb 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 248
This repository was archived by the owner on Feb 22, 2024. It is now read-only.
[Suggestion] Improve Algolia Indexing #343
Copy link
Copy link
Open
Description
Hi there 👋
I am the maintainer of the Algolia Library and I noticed you are using it! That's awesome.
I was curious and I took a look at the code base and I found out this part we could improve.
discoverdotnet/src/DiscoverDotnet/Modules/UpdateSearchIndex.cs
Lines 51 to 66 in e5e6a21
| BrowseIndexResponse<JObject> results; | |
| int page = 0; | |
| do | |
| { | |
| RequestOptions options = new RequestOptions | |
| { | |
| QueryParameters = new Dictionary<string, string> | |
| { | |
| { "page", page.ToString() } | |
| } | |
| }; | |
| results = await index.BrowseFromAsync<JObject>(new BrowseIndexQuery(), options, context.CancellationToken); | |
| existing.AddRange(results.Hits); | |
| page++; | |
| } | |
| while (page < results.NbPages); |
To get the entire index, one could simply do that:
var results = new List<JObject>();
foreach (var item in index.Browse<JObject>(new BrowseIndexQuery()))
{
results.Add(item);
}Browsing with the page parameter can lead to some issue. It's better to use the built-in Browse method.
Happy to PR this change if you would like!
khalidabuhakmeh
Metadata
Metadata
Assignees
Labels
No labels