Guest User

Untitled

a guest
Apr 26th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. // ObjectIDs = IDs of the
  2.  
  3. index.search({
  4. query: documentId,
  5. attributesToRetrieve: ['objectID'],
  6. hitsPerPage: 100,
  7. distinct: false,
  8. }, function searchDone(err, content) {
  9. if (err) {
  10. console.error(err);
  11. return;
  12. }
  13.  
  14. // We get the IDs to delete (the current ones corresponding to the document)
  15. const objectIDs = content.hits.map(hit => hit.objectID)
  16.  
  17. index.deleteObjects(objectIDs, function(error, content) {
  18. if (!error) {
  19. index.waitTask(content.taskID, function(err) {
  20. if (err) {
  21. console.log(err);
  22. } else {
  23. console.log('content', content)
  24. // console.log('objects to add', objectsToAdd)
  25. index.addObjects(objectsToAdd, function(e, content) {
  26. // e ? true : console.log(content)
  27. });
  28. }
  29. });
  30. } else {
  31. console.log(error)
  32. }
  33. });
  34. );
Add Comment
Please, Sign In to add comment