I am trying to modify querybuilder code to nest some conditions.
The section of my querybuilder code is as follows:
fulltext=searchterm
group.0_path=/content/path1
group.0_path.self=true
group.1_path=/content/path2
group.1_path.self=true
group.p.or=true
orderby=@jcr:score
orderby.sort=desc
property=jcr:content/excludeFromSearch
property.operation=not
2_property=jcr:content/cq:redirectTarget
2_property.operation=not
type=cq:Page
p.limit=-1
Resulting XPath is:
//element(*, cq:Page)
[
(jcr:contains(., 'searchterm')
and not(jcr:content/@excludeFromSearch)
and not(jcr:content/@cQ:redirectTarget))
]
order by @jcr:score descending
I would like to add a 3rd property that can be grouped with the second, so the logic is
not(jcr:content/@excludeFromSearch)
and
(not(jcr:content/@cq:redirectTarget) or (jcr::content/@NEWPROPERTY))
The new property, if it exists, will negate the cq:redirectTarget property. Any help is appreciated.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @HN_Doug To achieve the desired nested conditions in the query, you can add a new group to the existing query with the required properties. The modified code for the querybuilder should look something like this:
fulltext=searchterm
group.0_path=/content/path1
group.0_path.self=true
group.1_path=/content/path2
group.1_path.self=true
group.2_property=jcr:content/@NEWPROPERTY
group.2_property.operation=exists
group.2_property.value=true
group.2_property.1_property=jcr:content/@cq:redirectTarget
group.2_property.1_property.operation=not
group.2_property.p.or=true
group.p.or=true
orderby=@jcr:score
orderby.sort=desc
property=jcr:content/excludeFromSearch
property.operation=not
2_property=jcr:content/cq:redirectTarget
2_property.operation=not
type=cq:Page
p.limit=-1
Hi @HN_Doug To achieve the desired nested conditions in the query, you can add a new group to the existing query with the required properties. The modified code for the querybuilder should look something like this:
fulltext=searchterm
group.0_path=/content/path1
group.0_path.self=true
group.1_path=/content/path2
group.1_path.self=true
group.2_property=jcr:content/@NEWPROPERTY
group.2_property.operation=exists
group.2_property.value=true
group.2_property.1_property=jcr:content/@cq:redirectTarget
group.2_property.1_property.operation=not
group.2_property.p.or=true
group.p.or=true
orderby=@jcr:score
orderby.sort=desc
property=jcr:content/excludeFromSearch
property.operation=not
2_property=jcr:content/cq:redirectTarget
2_property.operation=not
type=cq:Page
p.limit=-1
Hi @HN_Doug As mentioned in your query above, there is a requirement to create 2 groups.
There is an option to include multiple groups while creating the queries.
Example:
Group Usage 1:
fulltext=Management
group.p.or=true
group.1_path=/content/geometrixx/en
group.2_path=/content/dam/geometrixx
Group Usage 2:
fulltext=Management
group.p.or=true
group.1_group.path=/content/geometrixx/en
group.1_group.type=cq:Page
group.2_group.path=/content/dam/geometrixx
group.2_group.type=dam:Asset
So as mentioned in the above sample (Group Usage 2) we have 1_group, 2_group. These are the multiple groups created. IMO, the second example should fix your problem.
Hope this helps!
Thanks
Views
Likes
Replies