Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

AEM query builder with mutiple types 6.5

Avatar

Level 8

Hi ,

I need to build query with different type and property 

 

Could some one help me on this

 

1>I have a property called as pagetitle under type cq:PageContent 

2>I have a property called as text under  type nt:unstructured  which also should match a sling property to avoid too much traversing of nodes

3> I would need a OR opertion for this 2 different type

So wrote the query as below  using querydebug.html but it does not give what i require

 

path=/content/project/us/en/computers/handheld/

orderby=@jcr:score

2_group.1_type=nt:unstructured

2_group.1_property=text

2_group.1_property.1_value=%battery%

2_group.1_property.2_value=%Battery%

2_group.1_property.operation=like

2_group.2_property=sling:resourceType

2_group.2_property.1_value=project/components/apps/text

2_group.2_type=cq:PageContent

2_group.2_property=pageTitle

2_group.2_property.1_value=%battery%

2_group.2_property.2_value=%Battery%

2_group.2_property.operation=like

2_group.p.or=true

 

 

Regards,

Srinivas

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

try with

path=/content/project/us/en/computers/handheld/
orderby=@jcr:score

group.1_group.type=nt:unstructured
group.1_group.1_property=text
group.1_group.1_property.1_value=battery
group.1_group.1_property.2_value=Battery
group.1_group.1_property.operation=like
group.1_group.2_property=sling:resourceType
group.1_group.2_property.value=project/components/apps/text


group.2_group.type=cq:PageContent
group.2_group.property=pageTitle
group.2_group.property.1_value=battery
group.2_group.property.2_value=Battery
group.2_group.property.operation=like
group.p.or=true



Arun Patidar

View solution in original post

5 Replies

Avatar

Community Advisor

Hi @srinivas_chann1 ,

 

Your query looks fine to me, are you getting any errors, or wrong results, after you execute it in query builder, do check the xpath generated query, that will give you an idea if something is missing from your query or if something is wrong with the syntax for the same.

If you are not able to figure out, please post the generated xpath query too, and what you need exactly which is not showing with the xpath generated query

 

Please refer this document for query builder syntax and reference:

https://github.com/paulrohrbeck/aem-links/blob/master/querybuilder_cheatsheet.md 

The query that was generated was :-
(
/content/project/us/en/computers/handheld//element(*, nt:unstructured)
|
/content/project/us/en/computers/handheld//*
[
((jcr:like(@pageTitle, '%Battery%')
or jcr:like(@pageTitle, '%battery%')))
])
order by @jcr:score
)

I don't see the cq:PageContent and sling resource property in the query generated .

I have added them like below

2_group.2_property=sling:resourceType

2_group.2_property.1_value=project/components/apps/text

2_group.2_type=cq:PageContent

 

How to get this  generated in query??

 

Regards,

Srinivas

Avatar

Correct answer by
Community Advisor

try with

path=/content/project/us/en/computers/handheld/
orderby=@jcr:score

group.1_group.type=nt:unstructured
group.1_group.1_property=text
group.1_group.1_property.1_value=battery
group.1_group.1_property.2_value=Battery
group.1_group.1_property.operation=like
group.1_group.2_property=sling:resourceType
group.1_group.2_property.value=project/components/apps/text


group.2_group.type=cq:PageContent
group.2_group.property=pageTitle
group.2_group.property.1_value=battery
group.2_group.property.2_value=Battery
group.2_group.property.operation=like
group.p.or=true



Arun Patidar

Avatar

Level 8

Thanks Arun for the inputs.

 

I see now the query almost what I need, I still have a question as why it does not show up  like 

//element(*, nt:unstructured)  and //element(*, cq:PageContent)  instead it just shows handheld//*??

 

Is this expected, internally it map to just types on the node??

 


  /content/project/us/en/computers/handheld//*
  [
  ((jcr:like(
@text'%Battery%')
  or jcr:like(@text, 
'%battery%'))
  and (@sling:resourceType = 
'project/components/apps/text'))
  ]
|
  /content/project/us/en/computers/handheld//*
  [
  ((jcr:like(
@pageTitle, '%Battery%')
  or jcr:like(@pageTitle, 
'%battery%')))
  ])
  order by 
@jcr:scor
)

 

 

 

 

Avatar

Community Advisor

Hi,

This is expected to filter out with type.



Arun Patidar