algolia / algoliasearch-client-csharp

⚡️ A fully-featured and blazing-fast C# API client to interact with Algolia.
https://www.algolia.com/doc/api-client/getting-started/install/csharp/
MIT License
120 stars 61 forks source link

v7 Migration questions #862

Closed morganleroi closed 2 months ago

morganleroi commented 2 months ago

Unfortunately v7 seems to a big step backwards in usability of the C# client. In my application I have a relatively small index of a few thousand records which gets regenerated when the source data changes. In v6 this is very simple using SearchIndex.ReplaceAllObjectsAsync.

In v7 there is no such thing and trying to check the documentation doesn't help as it's not been updated for the v7 changes (here for example)

In trying to figure out a migration path for this (since the migration guide doesn't make any mention of this) by digging through the v6 code, I can see that in v6 ReplaceAllObjectsAsync simply indexes the new objects in a temporary index and then uses MoveIndex to replace the live index with the temporary one.

Buy yet again, there is no "MoveIndex" method to be found anywhere. When I look at the new docs page page, what used to be a simple

var client = new SearchClient(new SearchConfig("YOUR_APP_ID", "YOUR_API_KEY"));
var index = client.InitIndex("destination");

await index.MoveFromAsync("source");

Appears to now be

var response = await client.OperationIndexAsync(
  "<SOURCE_INDEX_NAME>",
  new OperationIndexParams
  {
    Operation = Enum.Parse<OperationType>("Move"),
    Destination = "<DESTINATION_INDEX_NAME>",
    Scope = new List<ScopeType>
    {
      Enum.Parse<ScopeType>("Rules"),
      Enum.Parse<ScopeType>("Settings")
    },
  }
);

That is a not a good change IMO and this is only one operation that directly affects my application. I've also found something similar in trying to figure out the new way of batch indexing multiple objects in a single go and that also seems to be equally unwieldy in v7 now.

Originally posted by @lee-m in https://github.com/algolia/algoliasearch-client-csharp/issues/852#issuecomment-2323472003

Fluf22 commented 2 months ago

Hey @lee-m 👋🏻 It seems there was a little confusion around the ReplaceAllOjectsAsync helper, which does exist in the new version of the C# API client, but is not easy to find. Indeed, when doing a search in the docs, right now, the new API version methods are not well linked... We are working on that, bear with us! Although, in the new client documentation, you can find that the helper has been indeed ported: under the Helpers section, you'll find it https://www.algolia.com/doc/libraries/csharp/v7/helpers/#replace-all-records

Don't hesitate to re-open this issue if you find that this answer doesn't fit what you were looking for! ☺️

lee-m commented 2 months ago

Thanks for the pointer @Fluf22. I hadn't found then when digging through v7 so will check it out.