Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ObjectIDs = IDs of the
- index.search({
- query: documentId,
- attributesToRetrieve: ['objectID'],
- hitsPerPage: 100,
- distinct: false,
- }, function searchDone(err, content) {
- if (err) {
- console.error(err);
- return;
- }
- // We get the IDs to delete (the current ones corresponding to the document)
- const objectIDs = content.hits.map(hit => hit.objectID)
- index.deleteObjects(objectIDs, function(error, content) {
- if (!error) {
- index.waitTask(content.taskID, function(err) {
- if (err) {
- console.log(err);
- } else {
- console.log('content', content)
- // console.log('objects to add', objectsToAdd)
- index.addObjects(objectsToAdd, function(e, content) {
- // e ? true : console.log(content)
- });
- }
- });
- } else {
- console.log(error)
- }
- });
- );
Add Comment
Please, Sign In to add comment