algoliasearch-client-javascript
algoliasearch-client-javascript copied to clipboard
after setSettings function, the settings are not affected...
index.setSettings({ 'customRanking': ['desc(followers)'] }).then(() => {
index.search('query string', {
attributesToRetrieve: ['firstname', 'lastname'],
hitsPerPage: 50,
}).then(({ hits }) => {
console.log(hits);
});
});
I wrote code like above, but the queried results are not sorted...
I'd like your help. Thanks
index
.setSettings({ customRanking: ['desc(followers)'] })
.wait() // essential; settings aren't synchronous
.then(() =>
index
.search('query string', {
attributesToRetrieve: ['firstname', 'lastname'],
hitsPerPage: 50,
})
.then(({ hits }) => {
console.log(hits);
})
);
indexing operations aren't synchronous, so you need to wait for completion if you want to do an operation based on it right after.