We have a component with a certain keyword field, which is located at the metadata tab.

Using the Broker API we would like retrieve the keyword for a certain component. The custom_meta is returning the keyword title. We can't use the taxonomy api to get the keyword object based on the keyword title. If we use the API for querying the item_categories_and_keywords table, the API is only returning the ITEM_REFERENCE_ID. We don't need this ID, because this is the ID of the component which we already have.

So my question: is there a way to use the broker.querying API to get the result rows, instead of getting a list with string values containing the item_reference_id?

In the API there is information about query.getQueryResult() but the method is protected, so we can't use it.

  • I don't think it is a duplicate - Mirjam is trying to NOT use taxonomies (as far as I can tell) – Nuno Linhares Nov 25 '13 at 11:38
  • Are you trying to get the com.tridion.taxonomies.Keyword object from the CustomMeta field or a list of related Keywords by a given Keyword title? Please clarify your question. – Nickoli Roussakov Nov 25 '13 at 14:35
  • Seems like we're looking for the custom meta for a given item, which I think Bart covers in this answer on the CD API. – Alvin Reyes Nov 26 '13 at 5:57
  • I am trying to get the com.tridion.taxonomies.Keyword object from the CustomMeta field. But the custom meta field is only returning the title. – Mirjam Nov 26 '13 at 16:28

First of all - interesting problem. I never had to get the Keyword itself before, so I'm very curious why you need it. I would appreciate if you gave more details about what you are trying to accomplish.

I couldn't find a simple straight forward solution (and by that I mean a one or two lines Broker API call to read the Keyword). Instead I came up with the helper method below (Java code):

public Keyword getKeyword(ComponentMeta meta, String fieldName) {
    CustomMeta custom = meta.getCustomMeta();
    Map<String, NameValuePair> map = custom.getNameValues();
    NameValuePair pair = map.get(fieldName);
    String value = (String) pair.getFirstValue();

    Category[] categories = meta.getCategories();
    for (Category category : categories) {
        for (Keyword keyword : category.getKeywordList()) {
            if (keyword.getKeywordName().equals(value)) {
                return keyword;

    return null;

Obviously there are plenty of checks missing from the code-above, but I hope the idea is clear: that is, we read the CustomMeta first and get the String value of the Keyword metadata field. Then we match this value to all keywords available under the getCategories() method. This is a list of Category object that the current ComponentMeta is tagged against. One word of caution here: since we are talking about several Categories, there might be the risk of a Keyword title clash (i.e. there might be more Keywords with the same title, since they belong to different Categories). So you would be better off passing in a parameter with the Category name, such that you don't need to iterate over all Categories.

You would use the sample above in the following manner:

// get somehow a ComponentMeta object
ComponentMetaFactory factory = new ComponentMetaFactory(PUBLICATION_ID);
ComponentMeta meta = factory.getMeta(COMPONENT_ID);

// call the helper method
Keyword keyword = getKeyword(meta, "process-type");
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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