Skip to content
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

Strapi Nested Relation Field , attributes not appearing #758

Open
da-kicks-87 opened this issue Jul 7, 2023 · 5 comments
Open

Strapi Nested Relation Field , attributes not appearing #758

da-kicks-87 opened this issue Jul 7, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@da-kicks-87
Copy link

Description
I have connected Strapi with Meilisearch official plugin.

I am testing in the Meilisearch Mini Dashboard. My Strapi "Product" content type appears in the search results.
However for its Relationship Field "Product Variants" the array's object is missing the "Photos" attribute and more.

Why is this? Is there a limit on the nested results?

Screenshots or Logs

Environment

  • OS: Mac
  • Meilisearch version: 1.2.0
  • strapi-plugin-meilisearch version: 0.9.2
  • Browser: Chrome
  • Strapi version: v4.11.4
@bidoubiwa
Copy link
Contributor

Hey @da-kicks-87 to add the nested fields in your final document, you should use the populate parameter from strapi. See this section https://github.com/meilisearch/strapi-plugin-meilisearch#-entries-query

@da-kicks-87
Copy link
Author

da-kicks-87 commented Jul 11, 2023

@bidoubiwa
I am using GraphQL and not REST API for Strapi so using populate didn't cross my mind.
I have tried your suggestion and i still doesn't work.

Here is my code from plugin.js

meilisearch: {
config: {
// Your meili host
host: env('MEILISEARCH_HOST'),
// Your master key or private key
//apiKey: env('MEILISEARCH_API_KEY'),
product : {
entriesQuery: {
populate: ['product_variants.photos', 'photos'],
},
},
},
}

As an alternative solution I am calling GraphQL from my search results page to get the the product_variant images and then matching the id with my base product with javascript loop.

This redundant since Meilisearch should be able to get the nest data.

@bidoubiwa
Copy link
Contributor

Hey @da-kicks-87, unfortunately we cannot do that as we cannot know to what extent we add the relationships? Do we also include the relations of the relations (etc etc...)? Adding listeners to these relationships would also be a mess. Unless we create a specific setting for it which feel free to suggest a solution for.

About the populate rule, I had a hard time making it work as well but it is meant for this exact purpose. Could you ask on strapi's side why it doesn't work?

@haZya
Copy link
Contributor

haZya commented Jul 14, 2023

Hey @da-kicks-87

Did you check if the attribute that you aren't getting is private or not? Because private attributes are not indexed AFAIK.

I wish this wasn't the case or there was an option to still index private attributes. This is because if I didn't want to get the private attribute value I could remove it from displayedAttributes or do a hacky workaround where I could use transformEntry to return null for that attribute that needs to be private. But there is no way to index that attribute without removing private in which case I'll have to sanitize it manually from the Strapi side.

@bidoubiwa Is this the case? Or am I missing something?

@bidoubiwa
Copy link
Contributor

Hey @haZya ! This was introduced in this PR https://github.com/meilisearch/strapi-plugin-meilisearch/pull/703/files

Could you create a new issue with your request? We can create a setting to allow private fields

@bidoubiwa bidoubiwa added the enhancement New feature or request label Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants