I am able to successfully use the contentful-to-algolia integration to import Contentful data into Algolia without any entry manipulation. Now, I would like to test changing the shape of the JSON so that entries are only indexed with specified properties.
Sync.sync(
<contentTypeID>,
<indexName>,
<callback function>
);
The last two parameters are what I am having issues with. Do I need to specify the <entryId>
parameter? I don't want to so I have been testing out values such as undefined
and false
but I get the error that a string is expected. What I care about is being able to run the manipulateSingle
function. If I don't put anything in the <entryID>
parameter and use this:
Sync.sync(
<contentTypeID>,
<indexName>,
<callback function>,
<manipulateSingle>
);
The sync works, entries are imported, and I don't get errors in the console. However, the manipulateSingle
function is ignored and my entries are not indexed with their new shape.
const formatter = ({
id,
createdAt,
locale,
productName,
slug,
productDescription,
tags,
contentType
}) => ({
id,
locale,
objectID: id,
createdAt,
productName,
slug,
productDescription,
tags,
contentType
});
Sync.sync(
'2PqfXUJwE8qSYKuM0U6w8M',
'blog',
function(algolia_response) {
const response = algolia_response;
console.log('res', JSON.stringify(algolia_response));
console.log('number of indexed entries:', algolia_response.length);
},
// undefined,
formatter
);