Last active
April 19, 2018 13:28
-
-
Save ahirel/285ad181938526755d758db4e6e44d19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) | |
} | |
}); | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment