Wildcard Case Insensitive AEM Query Builder
I want to search a text in lower case in query builder api in aem. For example my node is /conent/mydata/stores. It has store id nodes, each store id node has store information in properties like storeName etc. I need to search store by storeName using query builder api. The search should work lower case as well as upper case. I have created following custom predicate but it works with equals text while I need wildcard search with like operation, I tried to create another custom predicate 'likeIgnoreCase' but is doesn't work. Kindly guide if someone has idea about it.
import com.day.cq.search.Predicate;
import com.day.cq.search.eval.AbstractPredicateEvaluator;
import com.day.cq.search.eval.EvaluationContext;
import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@8220494(factory = "com.day.cq.search.eval.PredicateEvaluator/equalsIgnoreCase")
public class CaseInsensitiveEquals extends AbstractPredicateEvaluator {
private static final Logger log = LoggerFactory.getLogger(CaseInsensitiveEquals.class);
static final String PREDICATE_PROPERTY = "property";
@9944223
public String getXPathExpression(Predicate predicate, EvaluationContext context) {
String property = predicate.get(PREDICATE_PROPERTY);
String value = predicate.get("value").toLowerCase();
return "fn:lower-case(@" + property + ") = '" + value + "'";
}
}

