5

I need to accomplish the following, and I can't find any working method for it.

We have articles with a custom metadata field of comma-separated keyword values, the code I've built split's by comma and then creates Criteria for each eg:

CustomMetaKeyCriteria metaField = new CustomMetaKeyCriteria("articleKeywords");

for(int i=0; i < keywords.length; i++){
  keywordCriterias[i] = new CustomMetaValueCriteria(metaField, keywords[k], FieldOperator.LIKE);
}

I then want to search against the other article's keywords, using the LIKE operator so it'll search for each keyword within its keyword metadata.

I've been unable to combine the Criteria into a single one though, could someone talk me through how to do this? Every approach I've tried has failed.

Thanks

1 Answer 1

6

@Kris, I am assuming you have custom meta value as a comma separated string. You can use SQL like pattern %% to match the value. So your custom meta value criteria should be like:

CustomMetaValueCriteria customMetaValueCriteria = new CustomMetaValueCriteria(metaField, "%keywordValue%", Criteria.Like); 

You can fit this code in your application code.

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.