Hi All, I'm having trouble with importing documen...
# community-help
s
Hi All, I'm having trouble with importing documents using upsert action. Reading this thread, it seems like several years ago the ask for doing an upsert import with a filter_by was discussed. And the linked Github issue is resolved. But I can't get it to work, and reading the documentation I'm not sure it was included for upserting. We're using v27.1. The use case is this: Changes in our tool generate new or updated documents for TypeSense. I'd like to be able to upsert these (so I don't have to worry about processing inserts and updates separately). And I'd like to be able to do it in bulk (since our tool generates hundreds or thousands of document upserts from a single business event). I can accomplish this with bulk import and action=upsert. But now I'm also wanting to control for race conditions. I'd like the update half of upsert to only occur if a certain filter_by is true (filter_by=lastUpdated:<{timestamp when I generated this document and queued it for syncing to typesense} Should this be possible? Using filter_by with import and action=upsert? If not, is there a recommended pattern for safely doing updates that may come out of order?
j
The /documents/import endpoint doesn't support
filter_by
, only the /documents endpoint support it. But I can see how this would be useful. Could you open a GitHub issue with this feature request?
s
@Jason Bosco Does the /documents/:id endpoint support filter_by? Or do I have to use /documents and then use a filter_by to specify the ID I'm targeting?
j
Does the /documents/:id endpoint support filter_by?
No, so you'll have to use the latter option you mentioned