Help on XPath Query | Community
Skip to main content
New Participant
May 31, 2016
Solved

Help on XPath Query

  • May 31, 2016
  • 3 replies
  • 1149 views

 Hello Team,

Am trying to create search functinality for our site. Whenever the user enters any string it searches all through the jcr content and return the results as pages.

But i wanted to restrict one thing.

I do not want to search the user entered string in url. For examples, if users searchs 'madhu' and in one page it contains hyperlink as "https://www.test.com/madhu/index.html", i do not want to return this page as the text does not contain in content rather in hyperlink source.

Please help!!

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

Hi 

A custom predicate could perform things that is directly not possible with XPath, for example:

  • looking up some data from some service
  • custom filtering based on calculation

Documentation link:- https://docs.adobe.com/docs/en/aem/6-0/develop/search/implementing-custom-predicate-evaluator.html

 

Reference Link:- https://hashimkhan.in/tag/xpath/

// Custom Predicate Evaluators:

Broadly there are 2 kinds of Predicate Evaluators which can be used to create new predicates as per Business need.

  • XPath Predicate: This is used to create a Backend XPATH Query using the new custom predicates which can be defined as per need. Many of the inbuilt CQ predicates are XPATH predicates. Notice that in XPATH Predicate Evaluator the overriden method canXpath() should return true while canFilter() should return false.  Use the below code snippet to create Custom Predicates :

Read More on the link.

I hope this would help you.

Thanks and Regards

Kautuk Sahni

3 replies

kautuk_sahni
kautuk_sahniAccepted solution
Employee
May 31, 2016

Hi 

A custom predicate could perform things that is directly not possible with XPath, for example:

  • looking up some data from some service
  • custom filtering based on calculation

Documentation link:- https://docs.adobe.com/docs/en/aem/6-0/develop/search/implementing-custom-predicate-evaluator.html

 

Reference Link:- https://hashimkhan.in/tag/xpath/

// Custom Predicate Evaluators:

Broadly there are 2 kinds of Predicate Evaluators which can be used to create new predicates as per Business need.

  • XPath Predicate: This is used to create a Backend XPATH Query using the new custom predicates which can be defined as per need. Many of the inbuilt CQ predicates are XPATH predicates. Notice that in XPATH Predicate Evaluator the overriden method canXpath() should return true while canFilter() should return false.  Use the below code snippet to create Custom Predicates :

Read More on the link.

I hope this would help you.

Thanks and Regards

Kautuk Sahni

Kautuk Sahni
GK-007
New Participant
May 31, 2016
Maddy737Author
New Participant
May 31, 2016

Maddy737 wrote...

 Hello Team,

Am trying to create search functinality for our site. Whenever the user enters any string it searches all through the jcr content and return the results as pages.

But i wanted to restrict one thing.

I do not want to search the user entered string in url. For examples, if users searchs 'madhu' and in one page it contains hyperlink as "https://www.test.com/madhu/index.html", i do not want to return this page as the text does not contain in content rather in hyperlink source.

Please help!!

 

Can someone please help!!