search for content in a content fragment that is referenced in another content fragment | Adobe Higher Education
Skip to main content
Level 2
February 5, 2025
Respondido

search for content in a content fragment that is referenced in another content fragment

  • February 5, 2025
  • 3 respostas
  • 1391 Visualizações

I'm implementing a search feature with the Query Builder API. This is a headless solution in which all content is content fragments, including the site's "pages"

 

This is my initial query and the query works when I search directly in content fragments of type "page"

type=dam:Asset
path=/content/dam/tap/master/pt/pages
property=jcr:content/data/cq:model
property.value=/conf/tap/settings/dam/cfm/models/page
fulltext=dummy test

 

My problem is when the word I'm looking for is in a content fragment that is being referenced

Example: 
If I search for the word holidays


It should have this path (/content/dam/tap/master/pt/pages/politica-de-privacidade/jcr:content/data/master) as a result because the word "holidays" exists within the content fragment (/content/dam/tap/master/pt/components/dark-hero-card) that is being referenced in the properties (ex: sections: ) of the content fragment (/content/dam/tap/master/pt/pages/politica-de-privacidade/jcr:content/data/master)

You can see the structure in the image

 




What are the possible solutions?

 

Melhor resposta por JoelSo2

I tried the index solution but it didn't work and then I implemented two queries, but depending on the word I was looking for sometimes it took 15 seconds to get an answer.

The only solution I found was to create a listener that looks for referenced content fragments within the main content fragment and then creates a "customIndexedData" field that stores all the information of the referenced content fragments.

So when I do fulltext search, it's fast and always finds the correct fragments

3 Respostas

anupampat
Community Advisor
Community Advisor
February 5, 2025

Hi @joelso2 ,

This will probably not be resolved via the Query Builder API alone, if you know that there could be search keywords present in the 'section' path, you would want to include another query on the value of 'section' combine both results and then return the result.

 

So First Query- to find the keyword under /content/dam/tap/master/pt and get the path of 'section'

and add the result of first query to

second query - fire on the value of 'section' path i.e. /content/dam/tap.

 

Regards,

Anupam Patra

JoelSo2Autor
Level 2
February 5, 2025

Is it possible to resolve this by creating a custom oak:index?

AmitVishwakarma
Community Advisor
Community Advisor
February 5, 2025

Yes, creating a custom oak:index is a correct and efficient solution to address your issue. By indexing the properties (like sections) that reference other content fragments, you ensure that the full-text search includes those referenced fragments as well.

Uppari_Ramesh
Level 5
February 7, 2025

Hi @joelso2 ,

 

Parent path:/content/dam/tap/master/pt/pages/politica-de-privacidade/jcr:content/data/master

Reference path:/content/dam/tap/master/pt/components/dark-hero-card

 

Here your requirement is to get the parent path instead of reference path but you are getting the reference path. As @anupampat mentioned, just querybuilder isn't just enough to achieve desired result. Once you get the reference path then you need to execute SQL2 query to get the parent path. The sample query would look like below

SELECT * FROM [nt:unstructured] AS node WHERE ISDESCENDANTNODE(node, '/content/path') AND CONTAINS(node.[sections], 'give reference path')

You can create the index for above query.

 

Thanks,

Ramesh.

kautuk_sahni
Community Manager
Community Manager
February 10, 2025

@joelso2 Did you find the suggestions helpful? Please let us know if you need more information. If a response worked, kindly mark it as correct for posterity; alternatively, if you found a solution yourself, we’d appreciate it if you could share it with the community. Thank you!

Kautuk Sahni
JoelSo2AutorResposta
Level 2
February 11, 2025

I tried the index solution but it didn't work and then I implemented two queries, but depending on the word I was looking for sometimes it took 15 seconds to get an answer.

The only solution I found was to create a listener that looks for referenced content fragments within the main content fragment and then creates a "customIndexedData" field that stores all the information of the referenced content fragments.

So when I do fulltext search, it's fast and always finds the correct fragments