You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Assuming that I know a document must be deleted during the index_many, we could batch the deletes as well:
# app/indices/movies_index.rbclassMoviesIndex < Typesensual::Index# The schema of the collectionschemadoenable_nested_fieldsfield'title',type: 'string'field'release_date\..*',type: 'int32',facet: truefield'average_rating',type: 'float',facet: truefield'user_count',type: 'int32'field'genres',type: 'string[]',facet: trueenddefindex(ids)Movies.where(id: ids).includes(:genres).find_eachdo |movie|
ifmovie.soft_deleted?yield:delete,{id: movie.id,}elseyield(id: movie.id,title: movie.title,release_date: {year: movie.release_date.year,month: movie.release_date.month,day: movie.release_date.day},average_rating: movie.average_rating,user_count: movie.user_count,genres: movie.genres.map(&:name))endendendend
I'm not sure about the syntax but something like this would be nice to give a collection of ids and the index decide to delete and even use the delete_many from the typesense client.
PoC:
# Current implementationdefinsert_many!(docs,batch_size: 100)docs.lazy.each_slice(batch_size).with_object([])do |slice,failures|
results=typesense_collection.documents.import(slice,return_id: true,action: 'upsert')failures.push(*results.reject{ |result| result['success']})endend
Hi there!
Assuming that I know a document must be deleted during the index_many, we could batch the deletes as well:
I'm not sure about the syntax but something like this would be nice to give a collection of ids and the index decide to delete and even use the delete_many from the typesense client.
PoC:
The text was updated successfully, but these errors were encountered: