8

I am trying to retrieve all Components which satisfy a certain schema, and i have chosen the method "IComponentFactory.FindComponents" to do this. This method accepts an "ExtendedQueryParameters" object, which contains a "MetaQueryValues" property on it. What should I be providing in the MetaQueryValues? it boils down to a key/value collection but i just need an example of what key/value pairs i should be passing in? For example im searching for all components satisfying the General schema, using the following code:

var queryParameters = new ExtendedQueryParameters();
queryParameters.PublicationId = "9";
queryParameters.QuerySchemas = new[] { "General" };
queryParameters.MetaQueryValues = new[] { new MetaQueryItem("What key?", "What value?") };
var components = ComponentFactory.FindComponents(queryParameters);
return components.ToList();

Does anybody have an example call they have made to the FindComponents method, which shows me what to send in the MetaQueryValues? The key/value pair cannot be null/empty - and i have tried all combinations (component name, title, etc) but i get nothing back (no error - just an empty list indicating no components found).

Maybe there is an alternative method i could/should be using?

Help please!

1 Answer 1

7

Seems like you are on the right track but with a couple of issues:

The QuerySchemas property takes an array of TCM IDs rather than the names of the schemas.

A MetaQueryItem allows to query on metadata that has been published into the Content Data Store database (Broker). In order for these queries to succeed you need to be searching on fields that are defined on the Metadata tab of your Component.

Hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.