introduced in version 2009, there is a new Query API for the Broker, since you haven't indicated what version you are asking your question on yet, I'll assume it's 2009, 2011 or 2013.
Items can be retrieved from the Broker by querying on various characteristics:
- System metadata (item type, title, publish date etc.)
- Custom metadata (anything from the metadata tab of the Component)
- Linked Keywords
For example:
string[] keywords = {"Audi"};
CategorizationCriteria c1 = new CategorizationCriteria(3, "Cars", keywords);
Query query = new Query(c1);
string[] results = query.ExecuteQuery();
foreach (string tcmuri in results)
{
Response.Write("<li>" + tcmuri + "</li>");
}
So this shows that a Query contains one (set of) Criteria, and optionally Criteria can have child Criteria. The Query returns you an array of strings, containing TCM URIs. These URIs you can use to load the actual content of the Component Presentation.
You can find all details in the API guides, available for download from the online documenation (requires login). Alvin also wrote a nice blog on the Custom Meta Criteria.
What you are asking for is to retrieve a list of all Meta keys and values, to base your filter on. There isn't really such a method, the idea behind the Query mechanism is that you know your Schema of the Published Content, and based on that, you already know what Meta keys are available.
The meta values is a different story, when these are Keywords, then they are known (as Taxonomy values), but if they are dates or text values, then they are just that, values. There are no indexes on the values themselves, nor is there a full text index or search capability on the content available.
One thing you can do of course is just fetch all Components with a given Template, and then get the metadata from that. Not sure if it's really what you are looking for but at least you get the idea of the possibilities:
string templateUri = "tcm:3-4-32";
ComponentPresentationFactory cpf = new ComponentPresentationFactory(3);
ComponentMetaFactory cmf = new ComponentMetaFactory(3);
Criteria criteria = new ItemTypeCriteria(16);
Query query = new Query(criteria);
foreach (string uri in query.ExecuteQuery())
{
ComponentPresentation cp = cpf.GetComponentPresentation(uri, templateUri);
// check if component presentation is published to the broker
if (cp != null)
{
IComponentMeta meta = cmf.GetMeta(uri);
CustomMeta customMeta = meta.CustomMeta;
foreach (DictionaryEntry de in customMeta.NameValues)
{
Response.Write(string.Format("{0}: {1} ({2})<br/>",
de.Key,
((NameValuePair) de.Value).Value,
((NameValuePair) de.Value).Name));
}
}
}