Does AEM Query builder API allow searching the Content Fragment Core component's content included within a Page? | Community
Skip to main content
Level 2
September 23, 2019

Does AEM Query builder API allow searching the Content Fragment Core component's content included within a Page?

  • September 23, 2019
  • 1 reply
  • 15668 views

Hi All,

Please advise if AEM Query builder API supports searching of Content Fragment's (Adobe's Core component) content included within a Page.

I have added a Content Fragment core component on an empty content page (newly created) and authored all the required values for the component including fragmentPath. The component renders as expected and displays the Content Fragment data. However, when I tried searching for the data within content fragment using the following sample queries through Query Builder Debugger, it did not return any results. I am not sure if any new predicates are needed to enable the search functionality for content fragments.

Query Builder query 1:

type=cq:Page

path=<search path>(e.g., /content/we-retail/us/en)

fulltext=<searchterm> (e.g., winter)

Query Builder query 2:

type=cq:Page

path=<search path>(e.g., /content/we-retail/us/en)

fulltext=<searchterm> (e.g., winter)

contentfragment

AEM Version: 6.3.3.0

AEM Core Components Version: 2.5.0

Any advise or guidance would be greatly appreciated. Thank you in advance.

kautuk sahni  smacdonald2008

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

1 reply

Adobe Employee
September 23, 2019

You can try a query similar to:

type=nt:unstructure

path=/content/we-retail/us

1_group.1_property=sling:resourceType

1_group.1_property.value=weretail/components/content/contentfragment

fulltext=winter

Level 2
September 23, 2019

berliant​ Thanks for your prompt reply!

However, the provided query does not seem to work (no search results) for the specified scenario (Trying to search content fragment component data included within page).

type=nt:unstructured

path=/content/we-retail/us/en

1_group.1_property=sling:resourceType

1_group.1_property.value=weretail/components/content/contentfragment

fulltext=winter

Please note that the actual content fragment data is not being saved within page node structure as it is only being referenced through the "fragmentPath" property. Also, the core content fragment component has already been proxied under we-retail directory/project - "/apps/weretail/components/content/contentfragment". Let me know if you have any questions.

Level 2
September 24, 2019

You need to index your custom properties: "about", "name", "age" etc.

The query that I provided executes the plan:

PLAN: [cq:Page] as [a] /* lucene:cqPageLucene(/oak:index/cqPageLucene) +(+:fulltext:winter +:fulltext:contentfragment) +:ancestors:/content/we-retail/us ft:("winter" "contentfragment") where (contains([a].[*], 'winter')) and (contains([a].[*], 'contentfragment')) and (isdescendantnode([a], [/content/we-retail/us])) */

It means that you need to edit cqPageLucene index by adding a dedicated property. For example, for "about" it should be something like:

Make sure that you re-index /oak:index/cqPageLucene prior of testing the query.


berliantThanks again for your response.

I have added the "about" property as specified under "cqPageLucene" and also re-indexed the "/oak:index/cqPageLucene" index. However, the debugger does not return any results yet. I have also tried restarting the AEM instance and re-indexing again.

Could you please review and let me know if any additional configurations are needed.

Find below the "Query Explanation" details.

Indexes Used

cqPageLucene(/oak:index/cqPageLucene)

Execution Time

Total time: 2 ms

Query execution time: 1 ms

Get nodes time: 1 ms

Execution Plan

[cq:Page] as [a] /* lucene:cqPageLucene(/oak:index/cqPageLucene) +(+:fulltext:career +:fulltext:contentfragment) +:ancestors:/content/we-retail/us ft:("career" "contentfragment") where (contains([a].[*], 'career')) and (contains([a].[*], 'contentfragment')) and (isdescendantnode([a], [/content/we-retail/us])) */

Logs

Parsing xpath statement: explain /jcr:root/content/we-retail/us//element(*, cq:Page)[(jcr:contains(., 'career') and jcr:contains(., 'contentfragment'))]

XPath > SQL2: explain select [jcr:path], [jcr:score], * from [cq:Page] as a where contains(*, 'career') and contains(*, 'contentfragment') and isdescendantnode(a, '/content/we-retail/us') /* xpath: /jcr:root/content/we-retail/us//element(*, cq:Page)[(jcr:contains(., 'career') and jcr:contains(., 'contentfragment'))] */

Literal used

Attempting optimisation

cost using filter Filter(query=explain select [jcr:path], [jcr:score], * from [cq:Page] as a where contains(*, 'career') and contains(*, 'contentfragment') and isdescendantnode(a, '/content/we-retail/us') /* xpath: /jcr:root/content/we-retail/us//element(*, cq:Page)[(jcr:contains(., 'career') and jcr:contains(., 'contentfragment'))] */ fullText="career" "contentfragment", path=/content/we-retail/us//*)

cost for reference is Infinity

cost for property is Infinity

cost for nodeType is Infinity

Evaluating plan with index definition Lucene Index : /oak:index/slingeventJob

No applicable IndexingRule found for any of the superTypes [nt:hierarchyNode, cq:Page, nt:base, mix:created]

Evaluating plan with index definition Lucene Index : /oak:index/versionStoreIndex

Evaluating plan with index definition Lucene Index : /oak:index/cqTagLucene

No applicable IndexingRule found for any of the superTypes [nt:hierarchyNode, cq:Page, nt:base, mix:created]

Evaluating plan with index definition Lucene Index : /oak:index/workflowDataLucene

No applicable IndexingRule found for any of the superTypes [nt:hierarchyNode, cq:Page, nt:base, mix:created]

Evaluating plan with index definition Lucene Index : /oak:index/socialLucene

No applicable IndexingRule found for any of the superTypes [nt:hierarchyNode, cq:Page, nt:base, mix:created]

Evaluating plan with index definition Lucene Index : /content/oak:index/enablementResourceName

Evaluating plan with index definition Lucene Index : /oak:index/authorizables

No applicable IndexingRule found for any of the superTypes [nt:hierarchyNode, cq:Page, nt:base, mix:created]

Evaluating plan with index definition Lucene Index : /oak:index/ntBaseLucene

Evaluating plan with index definition Lucene Index : /oak:index/lucene-spellcheck

Applicable IndexingRule found IndexRule: nt:base

Evaluating plan with index definition Lucene Index : /oak:index/lucene

Applicable IndexingRule found IndexRule: nt:base

Evaluating plan with index definition Lucene Index : /oak:index/commerceLucene

No applicable IndexingRule found for any of the superTypes [nt:hierarchyNode, cq:Page, nt:base, mix:created]

Evaluating plan with index definition Lucene Index : /oak:index/cqProjectLucene

No applicable IndexingRule found for any of the superTypes [nt:hierarchyNode, cq:Page, nt:base, mix:created]

Evaluating plan with index definition Lucene Index : /oak:index/cqMobileAppLucene

No applicable IndexingRule found for any of the superTypes [nt:hierarchyNode, cq:Page, nt:base, mix:created]

Evaluating plan with index definition Lucene Index : /oak:index/damAssetLucene

No applicable IndexingRule found for any of the superTypes [nt:hierarchyNode, cq:Page, nt:base, mix:created]

Evaluating plan with index definition Lucene Index : /oak:index/cqPageLucene

Applicable IndexingRule found IndexRule: cq:Page

cost for lucene-property[/oak:index/cqPageLucene] is 8608.0

Full-text index without plan: "career" "contentfragment"

cost for aggregate lucene is Infinity

looking for plans for paths : []

cost for solr is Infinity

cost for traverse is Infinity

No alternatives found. Query: select [a].[jcr:path] as [jcr:path], [a].[jcr:score] as [jcr:score], [a].[jcr:primaryType] as [jcr:primaryType], [a].[jcr:createdBy] as [jcr:createdBy], [a].[jcr:created] as [jcr:created] from [cq:Page] as [a] where (contains([a].[*], 'career')) and (contains([a].[*], 'contentfragment')) and (isdescendantnode([a], [/content/we-retail/us]))