AEM query builder with mutiple types 6.5 | Community
Skip to main content
srinivas_chann1
Level 7
June 2, 2022
Solved

AEM query builder with mutiple types 6.5

  • June 2, 2022
  • 2 replies
  • 1335 views

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

 

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 arunpatidar

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

2 replies

Anmol_Bhardwaj
Community Advisor
Community Advisor
June 2, 2022

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 

srinivas_chann1
Level 7
June 2, 2022

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 @6655266: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

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
June 2, 2022

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
srinivas_chann1
Level 7
June 2, 2022

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(
@2107369, '%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 
@6655266:scor
)

 

 

 

 

arunpatidar
Community Advisor
Community Advisor
June 6, 2022

Hi,

This is expected to filter out with type.

Arun Patidar