querybuilder.json

Avatar

Avatar

rachnam30969196

Avatar

rachnam30969196

rachnam30969196

09-11-2017

We are working on building aem search query using REST API, Tag based conditions are include & excludeTags.

We are able to use tagId in the include tag options which includes all the children tags and backlinks in the query while we are not able use tagids for the negation, I have to use property for unequals operation.

if we compare following two property filters from the filters defined in the link.

2_tagid.property=jcr:content/cq:tags

2_tagid.2_value=structure:medicines

2_tagid.and=true

6_property.operation=unequals

6_tagid.property=jcr:content/cq:tags

6_tagid.1_value=structure:hotel

I couldn't use 6_tagid.operation=unequals to negate it and had to go back to property which doesn't include children and backlink tags in the query and it's doing exact tag match.

Is it intentional in AEM for performance reasons? if not how can use tagid in the excludeTags?

Thanks,

Rachna

Replies

Avatar

Avatar

arjun07180302

Avatar

arjun07180302

arjun07180302

09-11-2017

Not sure If I understand the question in context. Were you not able to use "unequals" operator in query builder API? and what is the version of AEM?

Avatar

Avatar

rachnam30969196

Avatar

rachnam30969196

rachnam30969196

10-11-2017

Yes in the querybuilder api, I am using http://localhost:4502/libs/cq/search/content/querydebug.htmlocalhost:4502/libs/cq/search/content/querydebug.html to generate the query with above include tags and exclude tags filters.

AEM version is 6.2 SP1 CFP4.

Thanks

Avatar

Avatar

kautuk_sahni

Community Manager

Total Posts

5.8K

Likes

1.0K

Correct Reply

1.1K

Avatar

kautuk_sahni

Community Manager

Total Posts

5.8K

Likes

1.0K

Correct Reply

1.1K
kautuk_sahni
Community Manager

10-11-2017

You can exclude the pages with certain properties using the property predicate evaluator. For ex. If you want to exclude pages which have the property "donotsearch" in its jcr:content node, then you can query it using property operation as exists.

map.put("path", "/content/geometrixx/en/toolbar"); map.put("type", "cq:Page"); /* Relative path to the property to check for */ map.put("property", "jcr:content/donotsearch"); /* Operation to perform on the value of the prop, in this case existence check */ map.put("property.operation", "exists"); /* Value for the prop, false = not, by default it is true */ map.put("property.value", "false"); 

This would result in the following XPath Query

/jcr:root/content/geometrixx/en/toolbar//element(*, cq:Page) [ not(jcr:content/@donotsearch) ] 

But in case you would like to exclude pages with certain value for the property donotsearch, then you can change the above query as shown below

map.put("property", "jcr:content/donotsearch"); //the property to check for map.put("property.operation", "equals"); // or unequals or like etc.. map.put("property.value", "/*the value of the property*/"); 

Source:- cq5 - How do I add a 'where not' to a QueryBuilder Query - Stack Overflow

Also,

Query Builder Samples

Source:- aem-links/querybuilder_cheatsheet.md at master · paulrohrbeck/aem-links · GitHub

~kautuk

Avatar

Avatar

rachnam30969196

Avatar

rachnam30969196

rachnam30969196

10-11-2017

Thanks Kautuk.

I have already gone through all the above, I can easily exclude the specific tag in the query but if you use tagid, it considers children tags and backlinks in the query, I couldn't exclude using tagid predicate.

2_tagid.property=jcr:content/cq:tags

2_tagid.2_value=structure:medicines

2_tagid.and=true

6_property.operation=unequals

6_tagid.property=jcr:content/cq:tags

6_tagid.1_value=structure:hotel

if you see my two above filters I have already used unequals operations with property which does exact mismatch of the tag specified, I want to have that tag plus it's children and backlinks in my query exclude operation,  I am able to do it in include tags using tagid predicate.(see above 2_ filter)

I hope it makes it more clear now.

Thanks,

Rachna