algolia / algoliasearch-django

Seamless integration of Algolia into your Django project.
https://www.algolia.com
MIT License
173 stars 65 forks source link

feat: adding save records endpoint #334

Open awaisdar001 opened 9 months ago

awaisdar001 commented 9 months ago
Q A
Bug fix? no
New feature? yes
BC breaks? no
Related Issue Fix https://github.com/algolia/algoliasearch-client-python/issues/561
Need Doc update yes

Describe your change

The provided change introduces an optimized solution for updating specific records within the Algolia search index efficiently. It addresses the challenges faced when dealing with a large number of products that require periodic updates.

What problem is this fixing?

The initial problem involved the impracticality of individually indexing a potentially large number of products, resulting in excessive API requests and a time-consuming process. The proposed solution introduces a save_records method that efficiently handles batch updates for specific products, streamlining the indexing process.

Key Changes Made:

  1. The save_records method has been added to handle batch updates for specific records in the Algolia index. This method efficiently processes records in batches, improving the overall time and resource utilization.

  2. The method utilizes a temporary index (__tmp_index) for storing and processing the updated records in batches.

  3. Records that should not be indexed are marked for deletion, ensuring the removal of outdated records from the index.

The delete_records method has been introduced to handle the deletion of multiple records from the Algolia index.

Impact and Benefits:

The changes provide a more streamlined and efficient workflow for handling periodic updates, addressing the outlined challenges. This enhancement contributes to a more responsive and user-friendly Algolia integration.

Additional Notes:

With limited experience in the codebase, I thoroughly explored the repository before proposing this solution. While I acknowledge the potential for oversight, I aimed to provide a preliminary solution and showcase a possible approach. Feedback and corrections are welcomed as opportunities for learning and improvement. Thank you for your guidance.

Please review the changes and provide feedback on the proposed solution.