Multiple order by clause (QueryBuilder) | Community
Skip to main content
New Participant
October 16, 2015
Solved

Multiple order by clause (QueryBuilder)

  • October 16, 2015
  • 7 replies
  • 5977 views

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

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

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

7 replies

New Participant
February 17, 2017

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

Lokesh_Shivalingaiah
New Participant
October 16, 2015
Sham_HC
New Participant
October 16, 2015

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

edubey
New Participant
October 16, 2015
New Participant
October 16, 2015

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?

New Participant
October 16, 2015

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.

Sham_HC
Sham_HCAccepted solution
New Participant
October 16, 2015

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