so I have an AEM query that looks like this:
nodename=master
group.p.or=true
group.1_property=title
group.1_property.value=%article%
group.2_property=body
group.2_property.value=%article%
group.1_property.operation=like
Now this gives me all the results where the property contains article but not if it contains Article or aRticle etc.
I would want to know if there's already an inbuilt predicate like `[13:46] Sahil, Shivam Oh okay actually I want to make a group query case insensetive: nodename=mastergroup.p.or=truegroup.1_property=titlegroup.1_property.value=%article% group.2_property=bodygroup.2_property.value=%article%group.1_property.operation=like
So this gives me result wherever the title contains article however not if it contains Article or aRticle etc etc
I want to know if we already have a predicate for which I can add something like:
group.1_property.caseSenstivity=false
otherwise I would be interested in extending property predicate one like:
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to
*/
package com.perficient.adobe.predicates;
import java.util.Locale;
import java.util.Optional;
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;
@Component(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";
static final String PREDICATE_VALUE = "value";
static final String PREDICATE_LOCALE = "locale";
@Override
public String getXPathExpression(Predicate predicate, EvaluationContext context) {
log.debug("Evaluating predicate: {}", predicate);
String property = predicate.get(PREDICATE_PROPERTY);
Locale locale = Optional.ofNullable(predicate.get(PREDICATE_LOCALE)).map(lt -> Locale.forLanguageTag(lt))
.orElse(Locale.getDefault());
String value = predicate.get(PREDICATE_VALUE).toLowerCase(locale).replace("'", "''");
String query = String.format("fn:lower-case(@%s)='%s'", property, value);
log.debug("Generated query: {}", query);
return query;
}
}
Can someone help me extending property predicate to caseInsensetiveProperty predicate where I can also specify if the search should have case insenstivity or not?