Expand my Community achievements bar.

SOLVED

Multiple order by clause (QueryBuilder)

Avatar

Level 5

Trying to user querybuilder and need to have multiple order by clauses. Tried this, doesn't work (in XPath I can see the order by doesn't get added). What's the correct syntax and where can I find more documentation on using these clauses?

1_orderby=@jcr:content/metadata/docType
1_orderby.sort=asc

2_orderby=@jcr:content/metadata/type
2_orderby.sort=asc

1 Accepted Solution

Avatar

Correct answer by
Level 10

If using [1] then put at beginning. If using xpath directly then put at last.   The correct syntax is last.

[1]  http://host:port/libs/cq/search/content/querydebug.html

View solution in original post

7 Replies

Avatar

Level 10

Try at [1] & will get added in sort.  If not added then please engage with official support team. 

[1]  http://host:port/libs/cq/search/content/querydebug.html

Avatar

Level 5

Sham,

I figured the issue, but I am not sure I understand how the querybuilder works. So I thought the number 1 before the order by (1_orderby) was for the first order by field. However that number seems global to the query I am executing.

 

What I mean is this, I had 2 properties I ws searching by

1_property=<property1>

2_property=<property2>

So apparently, the orderby needed 3_ instead of 1_. Kind of does not make sense to me. I thought that number was for the clause not the query.

 

Is there some documentation that explains what the numbers mean or rather documentation of different queries you can execute and how multiple clauses can be used?

Avatar

Level 5

Sham,

Also need some documentation to understand the significance of @ in queries. For example in here

~~","@jcr:content/metadata/jcr:lastModified

~~","jcr:content/metadata/@jcr:lastModified

 

when do we put @ before the entire path or at the last? Because both seem to work.

Avatar

Correct answer by
Level 10

If using [1] then put at beginning. If using xpath directly then put at last.   The correct syntax is last.

[1]  http://host:port/libs/cq/search/content/querydebug.html

Avatar

Level 1

Hi, I am facing same issue.

The search query has two orderby clause but it is not coming in xpath query.

Query:

[
    {fulltext=fulltext: fulltext=generation}
    {orderby_group=orderby_group: 2_orderby.index=true, 1_orderby=@jcr:score, 2_orderby=@jcr:content/modified_date, 2_orderby.sort=desc, 1_orderby.sort=desc, p.and=true, 1_orderby.index=true}
    {path=path: path=/content/test/books}
    {1_group=group: or=true[
        {1_property=property: property=@jcr:content/offTime, operation=not}
        {2_daterange=daterange: property=@jcr:content/offTime, lowerBound=2017-02-16T10:20:36.016Z, lowerOperation=>=}
    ]}
    {2_group=group: [
        {1_type=type: type=cq:Page}
    ]}
]
Warning: no PredicateEvaluator found for 'orderby_group'
xpath query: /jcr:root/content/test/books//element(*, cq:Page)[jcr:contains(., 'generation') and (not(jcr:content/@offTime) or (jcr:content/@offTime >= xs:dateTime('2017-02-16T10:20:36.016Z')))]

 

Could you please help?

Regards,

Swati