Custom populate options per entity
See original GitHub issueRelated to: https://github.com/meilisearch/strapi-plugin-meilisearch/issues/376#issuecomment-1123932008
Description It’d be very useful to have custom populate options per content/entity type so that we have more control over what data gets indexed and we have access to it in the transform functions.
I imagine a config like this would be fine
ENTITY: {
settings: {
...
populate: {
field: '*'
},
...
Basic example Sometimes you have more complex data structures with deep nested components and references and you need access to the underlying information or at the very least to have it available in the index.
For example, if you have a single use component field with a component referencing another content type, such as a date period component referencing a timezone, the generic populate: ‘*’ doesn’t currently cover the deep nesting required.
This is the patch we’ve used to add our custom populate for one content type, ideally you can override the populate: '*'
instead.
diff --git a/node_modules/strapi-plugin-meilisearch/server/services/content-types/content-types.js b/node_modules/strapi-plugin-meilisearch/server/services/content-types/content-types.js
index 1e5f6a2..5adf3dd 100644
--- a/node_modules/strapi-plugin-meilisearch/server/services/content-types/content-types.js
+++ b/node_modules/strapi-plugin-meilisearch/server/services/content-types/content-types.js
@@ -142,7 +142,27 @@ module.exports = ({ strapi }) => ({
limit = 500,
filters = {},
sort = {},
- populate = '*',
+ populate = {
+ programme: {
+ populate: {
+ programme_logo: '*'
+ }
+ },
+ event_type: '*',
+ featured_image: '*',
+ topics: '*',
+ languages: '*',
+ location: {
+ populate: {
+ country: '*',
+ }
+ },
+ dates: {
+ populate: {
+ timezone: '*',
+ }
+ },
+ },
publicationState,
}) {
const contentTypeUid = this.getContentTypeUid({ contentType })
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Wait…I think I’m just confused 😅
Ignore me, I’ll open a separate issue with the explainer if it’s still a problem for us next week.
Thanks again for your fast work on these plugin issues!
Could you explain how it would work and how it is different?