I need to query for components that have the same component linked inside a metadata multi value component field. e.g. as shown in the image below, I want to query for components for which AuthorExpertLinks is not null, and I want to know if one of the AuthorExpertLink components matches the "expert" I am currently displaying (so that the website can display a card to link to an application note that the "expert" has authored. I could work out how to use CustomMetaValueCriteria etc to look for a static string, but I don't know how to use the broker query for the kind of component links described above. Does anyone know how to do this?
1 Answer
Querying for components based on a link field is technically possible (the link is treated as a text field in the broker database, iirc) but not a good idea. Keywords are much better suited for this purpose. You could create the following:
- a category 'Authors', with keywords for each author
- a schema 'Author', with a (content or metadata) keyword field linking to that category
- a schema 'Article' (or similar), also linked to the same category
Now, it's easy to create lists of articles related to an author, or to find the author(s) for an article. The broker API has a number of criteria for this, like the CategorizationCriteria.
-
1I've gone for exactly your suggested solution, thanks Commented Apr 14, 2023 at 11:53