Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

[Suggestion] Improve Algolia Indexing #343

@Ant-hem

Description

@Ant-hem

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.

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions