AEM 6.2 "fn:lowercase" is not working | Community
Skip to main content
Unnikrishnankv
Level 3
January 3, 2017

AEM 6.2 "fn:lowercase" is not working

  • January 3, 2017
  • 2 replies
  • 8820 views

Dear Team,  

. How I can incoperate case sensitive search in AEM 6.2 with predicates.

I have tried below mentioned code unfortunately it doesn't work for me.But it is working fine in  5.6.1

Predicate authorNamePredicate = new Predicate("@authorName", "property");
authorNamePredicate.set(JcrPropertyPredicateEvaluator.OPERATION, JcrPropertyPredicateEvaluator.OP_LIKE);
                 authorNamePredicate
                     .set("property", "@fn:lower-case(@" + JcrConstants.JCR_CONTENT + "/" + "authorName" + ")");
                 authorNamePredicate.set("value", "%" + author.toLowerCase() + "%");
                 authorgroup.add(authorNamePredicate);

 

@fn:lower-case(" - is converted to fn:lower-case_x0028_  this is creating issue in AEM 6.2

 "/jcr:root/content/geo//*[@jcr:primaryType = 'cq:Page' and not(jcr:content/@hideInNav) and jcr:content/@jcr:title != 'Master Article' and jcr:like(fn:lower-case_x0028_/jcr:content/@authorName_x0029_, 'soumik dey')]/rep:excerpt(.) order by jcr:content/@cq:lastModified descending" This is the query it generating 

 

Thanks!

Unnikrishnan

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

kautuk_sahni
Community Manager
Community Manager
January 3, 2017

Hi 

Please have a look at this forum thread:-

Link:- http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manager.topic.html/forum__scgy-we_r_runningaquery.html

//  we never officially supported functions.  Hence not a bug. You have to file enhancement request to support xpath function. it is a known problem with the OAK repository

Please create a day care ticket for this.

 

Reference post telling about toupper/toLower in AEM :- http://www.wemblog.com/2013/04/how-to-create-custom-query-predicate-in.html

// You need to create a create custom query predicate.

I hope this would help you.

~kautuk

Kautuk Sahni
Unnikrishnankv
Level 3
January 3, 2017

Thank you  kautuk , I have tried custom predicate in this case it throwing same error like "java.text.ParseException: Query". Am using  fn:lowercase with predicates not in query.  I have raised to  Adobe team internally  and they created Day care ticket for that. Can you confirm  xpath queries are not supported in AEM 6.2 ? It will helpful for us . Our search concept working with predicates, so we need to change entire search code if it not supported.

Thanks!, 

Unnikrishnan

January 16, 2018

Hi Kirshnan,

Is this issue solved? I am also facing the same issue, let me know creating the day care tickets helped?

Thanks,

Ravi

edubey
Level 10
January 16, 2018

This is not the exact code which you would need but should help you to proceed.


import com.day.cq.search.Predicate;
import com.day.cq.search.eval.AbstractPredicateEvaluator;
import com.day.cq.search.eval.EvaluationContext;
import org.apache.felix.scr.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.jcr.query.Row;

/**
* Custom case insensitive predicate for like operation
* caseinsensitive.property=jcr:content/@jcr:title
* caseinsensitive.value= queryString %
*
*/
@Component(
metatype = false,
factory = "com.day.cq.search.eval.PredicateEvaluator/caseinsensitive"
)
public class CaseInsensitiveLikePredicate extends AbstractPredicateEvaluator
{
public static final String PROPERTY = "property";
public static final String VALUE = "value";
public static final String WILDCARD = "%";
@Override
public boolean includes(Predicate predicate, Row row, EvaluationContext context)
{
if (predicate.hasNonEmptyValue(PROPERTY))
{
return true;
}
return super.includes(predicate, row, context);
}

@Override
public String getXPathExpression(Predicate predicate, EvaluationContext context)
{
if (!predicate.hasNonEmptyValue(PROPERTY))
{
return null;
}
if(predicate.hasNonEmptyValue(PROPERTY) && null==predicate.get(VALUE)){
return super.getXPathExpression(predicate, context);
}
if (predicate.hasNonEmptyValue(PROPERTY))
{
predicate.get(VALUE);
if (WILDCARD.equals(predicate.get(VALUE))) {
logger.info("Case Insensitive Query only has wildcard, ignoring predicate");
return "";
}
logger.info("jcr:like(fn:lower-case(" + predicate.get(PROPERTY) +"), '" +predicate.get(VALUE).toLowerCase()+ "')");
return "jcr:like(fn:lower-case(" + predicate.get(PROPERTY) + "),'" +predicate.get(VALUE).toLowerCase()+ "')";
}
return null;
}
}
Unnikrishnankv
Level 3
January 19, 2018

Thanks you ,

It is working .i have already implemented in my project and i forgot to mentioned here .. 

Level 2
May 17, 2021

@unnikrishnankv , Can you please mention how you got this issue resolved?