-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
partialUpdateObject remove some fields #781
Comments
Hello @CedricJezequel, I can not really repro your issue. const algoliasearch = require('algoliasearch');
// Use admin api key to set settings
const clientAdmin = algoliasearch('KECOEVPMGH', 'ADMIN_API_KEY');
const indexAdmin = clientAdmin.initIndex('repro');
await indexAdmin.setSettings({
"attributesToRetrieve": [
"title"
],
"unretrievableAttributes": [
"date"
],
}).wait();
// Use write api key that do not have rights to retrieve `date`
const client = algoliasearch('KECOEVPMGH', 'WRITE_API_KEY');
const index = client.initIndex('repro');
await index.saveObject({
objectID: 'my-object',
title: 'bar',
date: 'monday'
}).wait();
const obj1 = await index.getObject('my-object');
console.log(obj1);
console.log('date should be undefined: %s', typeof obj1.date === 'undefined')
await index.partialUpdateObject({
objectID: 'my-object',
score: 1,
}).wait();
const obj2 = await index.getObject('my-object');
console.log(obj2);
console.log('date should be undefined: %s', typeof obj2.date === 'undefined')
// check with admin
const obj3 = await indexAdmin.getObject('my-object', {
attributesToRetrieve: "*"
});
console.log(obj3);
console.log('date should not be undefined: %s', typeof obj3.date !== 'undefined')
console.log('score should not be undefined: %s', typeof obj3.score !== 'undefined') The output: Object {title: "bar", objectID: "my-object"}
"date should be undefined: true"
Object {title: "bar", objectID: "my-object"}
"date should be undefined: true"
Object {title: "bar", date: "monday", score: 1, objectID: "my-object"}
"date should not be undefined: true"
"score should not be undefined: true" As you can see the field Maybe you have missed something or the last part |
Hello @bodinsamuel, |
Yeah I used JS for simplicity but it works the same way, there is no logic in the API clients that would explain your issue. |
Yes, it's almost the same code, we just use browseFrom method to retrieve all datas needed to be updated, make a loop on it on save all with partialUpdateObjects method. As we do not use Async method available on JAVA framework, no wait has been put :
|
Okay I see, nothing seems incorrect here. The last thing that could be explaining this: In the Algolia Back Office the person checking as all the permissions? The hidden fields are in the "Show more attributes" If all correct then I'll reach out the Indexing team, as I don't have any more clue. |
Description
We implemented a new agent which update existing items from an Algolia index and we observed that partialUpdateObject does not work as expected : some fields, not declared in attributesToRetrieved, are removed when saving an updated item.
Steps To Reproduce
=> Items saved only have [objectID,title,text, url, source, score] fields and no more [date, subSource] fields
The text was updated successfully, but these errors were encountered: