Adding custom predicate | Community
Skip to main content
Sep 28, 2016 9:07 PM UTC

Adding custom predicate

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.

19 replies

venkatreddyguda
Level 2
May 9, 2019 1:19 PM UTC

Hi,

Did you succeed in this?

Pls can you share the steps.

Thanks,

Venkat

Translate
smacdonald2008
Level 10
May 9, 2019 2:28 PM UTC
venkatreddyguda
Level 2
May 9, 2019 6:30 PM UTC

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

Translate
AnkurAhlawat-1
Level 6
Jan 19, 2018 1:51 PM UTC

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.

Translate
smacdonald2008
Level 10
Sep 29, 2016 5:43 PM UTC

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? 

Translate
Sep 29, 2016 7:21 PM UTC

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.

Translate
smacdonald2008
Level 10
Sep 29, 2016 8:07 PM UTC

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. 

Translate
smacdonald2008
Level 10
Sep 28, 2016 9:43 PM UTC

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

Translate
Sep 29, 2016 2:58 PM UTC

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.

Translate