Adding custom predicate | Community
Skip to main content
September 28, 2016

Adding custom predicate

  • September 28, 2016
  • 4 replies
  • 9414 views

In the attached picture, how can I add in my own custom predicate. That is the edition search form page btw.

My use case is I'm trying to search for a property but need a 'LIKE' constraint in there. The

OOTB property predicate currently doesn't do that.

 

Thanks you

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

4 replies

smacdonald2008
Level 10
September 28, 2016

Because ootb one does not do that -- you can write your own using Java - this API: com.day.cq.search.PredicateGroup.

See this article as an example: 

https://helpx.adobe.com/experience-manager/using/customtags1.html

Hope this helps....  

September 29, 2016

Sorry if I wasn't clear. I want to add my own custom predicate into that list. So I can tie my custom component in with my own query.

So when I edit a search form I want to be able to see my custom predicate in that list and add that into the form.

smacdonald2008
Level 10
September 29, 2016

I have never attempted to configure the search form. However - here is the docs: 

https://docs.adobe.com/docs/en/aem/6-1/administer/operations/search-forms.html

Looks like you can configure a lot there. Look at the section title: ADDING OPTIONS PREDICATES. Looks like you can overlay some nodes to meet your requirements. Have you tried that? 

September 29, 2016

I looked into that however it will still function the same as putting in an property predicate. I need to change up how the property predicate queries in the back end

and looking ways to extend this.

smacdonald2008
Level 10
September 29, 2016

The best way to achieve your backend (predicate queries in the back end) is to write your custom back end using Java API (ie -https://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/Predicate.html)  and then hook into that from an overlay. Without writing your own logic - you are limited to what the OOTB ones do - as you stated they do not do what you need them to do. 

AnkurAhlawat-1
Level 6
January 19, 2018

For adding a custom asset search predicate, you need to create 3 things:-

  • overlay and add your field -  /libs/settings/dam/search/facets/formbuilderconfig/predicatetypes/items/<fulltext>
  • Create a field property resource - dam/gui/coral/components/admin/customsearch/formbuilder/predicatefields/fulltextpredicatefield
  • Create field resource type - dam/gui/coral/components/admin/customsearch/searchpredicates/fulltextpredicate
  • Select a field resource view(How it should look) - granite/ui/components/foundation/form/textfield

Your back end logic will hook into Step 2 and 3.

venkatreddyguda
Level 2
May 9, 2019

Hi,

Did you succeed in this?

Pls can you share the steps.

Thanks,

Venkat

smacdonald2008
Level 10
May 9, 2019
venkatreddyguda
Level 2
May 9, 2019

I created custom asset search predicate and able to see under Assets Admin Search Rail

Now i want to know how i can connect this custom asset search predicate to my predicate evaluator in the backend.

Thanks,

Venkat