We have a Component in which a Keyword is linked to one meta field and we were searching for the Component by its Key
TcmUri[] retrieveComponentTcm(String code, int publicationId) throws StorageException {
Criteria isHSchema = schemaCriteria(H_SCHEMA_ID);
Criteria hasHKeyword = taxonomyCriteria(publicationId, H_CATEGORY_ID, PUBLICATION_TARGET, code);
Query query = new Query(and(isHSchema, hasHKeyword));
return executeQuery(query);
}
Now the same Category is linked also to a second field and the query is failing. For example in the following scenario:
COMPONENT 1 field 1 = X field 2 = Y
COMPONENT 2 field 1 = Y field 2 = X
when I search by the Key Y, I'm retrieving 2 Components, but we only want to retrieve COMPONENT2 (the Component with the field1 = Y).
Is there any solution? We only have the Key of the Keyword.
UPDATE We need to recover components based on a schema and that have linked a keyword in a specific metadata field. This category is used in two metadata fields in this component. The problem is that I want to recover only the components with this keyword linked in one specific field and I can't make a CustomMetaValueCriteria, because I don't have the value of the keyword, but the key. As we are using Web8 and this category is publishable, my question was if there's a way of doing that only knowing the key.