Querybuilder query multiple paths and other properties | Community
Skip to main content
Level 9
January 12, 2022

Querybuilder query multiple paths and other properties

  • January 12, 2022
  • 2 replies
  • 7931 views

I do have a question on query builder query and if it is the apt way to proceed on 6.5.8

I have a structure as below

/var/test/user

  /A

    /0222223ead

  /B

   /234534rrr43 

and  58 more direct children for /var/test/user

I want to query for a property with a value "x", and link contains "/content/dam/y" and within a date range for "created" ordered by "created" and sort it.

 

The Querybuilder query i can think of is below. I would like to know if there is 

1. a limit to the number of "group" keyword used, while i am sure passing too many will perhaps lead to bad request with too many header fields.

2. way to optimize the query for a system with huge number of nodes under that structure (nested 8 levels deep)

3.Should i split it into multiple queries and merge?

4. Using below query should i be seeing "Filtering predicates"  displaying something? It appears to be blank in Query builder 

 

 

Takes 50 seconds 

 

Query

type=nt:unstructured
group.1_path = /var/test/user-info/0
group.2_path =/var/test/user-info/1

:

:

group.n_path =/var/test/user-info/n

group.p.or=true
1_property = action
1_property.value = X
2_property = @16075337/link
2_property.operation = like
2_property.value = /content/dam/y/assets/%
3_daterange.property = created
3_daterange.upperBound = 2022-01-01T12:09:00.000-05:00
3_daterange.lowerBound = 2021-06-01T12:09:00.000-04:00
orderby = created
orderby.sort = desc
p.limit=40000
p.offset=0
p.guesstotal=40000

 

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

2 replies

DEBAL_DAS
New Member
January 12, 2022

Here , user-info [/var/test/user-info] is having 60 children and you are targeting immediate children of 0,1.... n.

I feel instead of having multiple groups associated with path, you could have used 

type= nodetype [jcr:primaryType] of 0222223ead, 234534rrr43 
path=/var/test/user-info

 

If incase node type [jcr:primaryType] of 234534rrr43, 0222223ead is similar to user-info node, in that case  you can get expected result by adding date range, required property like action, link. 

 

Suppose you are targeting nodes[children] under multiple paths like /var/test/user-info and /var/test/demo and both are having different types children [jcr:primaryType], then you can use group associated with paths.

 

Below you could see I am targeting nodes like 425b2b8f-50f0-45ab-b8b4-e210d906b71c and my query -

type=cq:AuditEvent
path=/var/audit/com.day.cq.wcm.core.page/conf/demo
1_property = cq:path
1_property.operation = like
1_property.value = /conf/demo/settings/wcm/templates/page-content%
p.limit=-1

 

 

As of now practically I haven't seen merging of two different query builder queries. 

 

Requesting @arunpatidar , @Jörg_Hoh and others to correct me and add more valuable points.

 

 

 

Debal Das, Senior AEM Consultant
arunpatidar
Community Advisor
Community Advisor
February 9, 2022

Hi @debal_das 

I don’t know the exact requirement but queries looks complex.

I would have used the SQL2 queries or create custom predicate in order to make it easier to manage.

Arun Patidar
arunpatidar
Community Advisor
Community Advisor
June 3, 2022

@arunpatidar  thanks for the response. For now, I have chosen grouping(10 at a time) with batching of results, but is there a way with the given requirement custom predicate evaluator can be used ? 


Yes, you can create a custom predicate

You can check the immediate child of path and return true otherwise false

https://hashimkhan.in/aem-adobecq5-code-templates/query-builder/ 

Arun Patidar
ibishika
Level 4
June 3, 2022

Happened to find the solution for this and thought of posting it. If you are adding the paths as below:

group.1_path = /var/test/user-info/0
group.2_path =/var/test/user-info/1

 

It does not take the paths into account and you end up getting all the results irrespective of paths.

 

Putting the paths under different groups and combining those groups into one with OR works. The query that works is below:

 

0_group.1_group.1_path = /content/path1

0_group.2_group.2_path = /content/path2

.

.

.

0_group.n_group.n_path = /content/pathn

0_group.p.or=true