Expand my Community achievements bar.

SOLVED

Help on XPath Query

Avatar

Level 4

 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!!

1 Accepted Solution

Avatar

Correct answer by
Administrator

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

View solution in original post

3 Replies

Avatar

Level 4

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!!

Avatar

Correct answer by
Administrator

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