Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Search SQL2 for JCR with Tags

Avatar

Level 4

Hi,

Here is the problem statement:

I am implementing a search service - taking any keyword as the input. It will be doing the search on all the content at certain path.

Search Results

The search results should show the keyword is in the Tag, it should come on the top.

Question : Using JCR SQL2, how to bring the search result with keyword match on the top ?

Any suggestions will be highly appreciated.

Thanks,

Jay

5 Replies

Avatar

Level 8

SELECT * FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/content/geometrixx-outdoors/en]) and s.[cq:tags] like '%apparel%'

Avatar

Level 4

Thanks Hemant. But my problem statement is different.

Let's consider an example:

1. Keyword search under certain path, say '/content/geometrixx-outdoors'

2. Search Results will look like this:

a.Results matching the keyword in the tags - they should come on top of the results.

b. Results matching anywhere else other than tags.

Question: How to have the search results on the top if they match the tags, than other results ?

Avatar

Level 10

What do you mean on the top - are you talking about ordering the result set?

Avatar

Level 8

try this SELECT s.[cq:tags] FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/content/geometrixx-outdoors/en]) and s.[cq:tags] = 'geometrixx-outdoors:season/winter' ORDER BY s.[cq:tags] DESC I changed the position to last of geometrixx-outdoors:season/winter tag on one of the pages I ran this query and I see pages with geometrixx-outdoors:season/winter tag on 3rd position appears last