Expand my Community achievements bar.

SOLVED

Search related query

Avatar

Level 9

Hi All,

We have a customized search which uses the below query to check for the keyword "ABC DEF"[which is provided as an input in search box on page]

SELECT DISTINCT Path FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/content/x/y]) AND (CONTAINS(s.[cq:tags],'ABC DEF^600') OR CONTAINS(s.blocktitle,'ABC DEF^400') OR (s.blocktitle LIKE 'ABC DEF%') OR CONTAINS(s.bodycopy,'ABC DEF^100') OR (s.bodycopy LIKE 'ABC DEF%') OR CONTAINS(s.headingText,'ABC DEF^10') OR (s.headingText LIKE 'ABC DEF%') OR CONTAINS(s.Author,'ABC DEF^400') OR (s.Author LIKE 'ABC DEF%') OR CONTAINS(s.headline,'ABC DEF^2') OR (s.headline LIKE 'ABC DEF%') OR CONTAINS(s.[jcr:title],'ABC DEF') OR (s.[jcr:title] LIKE 'ABC DEF%')) AND ( NOT [hideInSearch] IS NOT NULL) ORDER BY 'jcr:lastModified'

Currently, it searches only for the keyword "ABC DEF" . The requirement is that it should search for occurences for "ABC", "DEF" and "ABC DEF" [when input provided in search box is "ABC DEF"].

So, we have come up with the below query[i.e, check for individual occurences of ABC and DEF words, so that the results got will match with our given requirement] :

SELECT DISTINCT Path FROM [nt:base] AS s WHERE ISDESCENDANTNODE([/content/x/y]) AND (CONTAINS(s.[cq:tags],'DEF^600') OR CONTAINS(s.blocktitle,'DEF^400') OR (s.blocktitle LIKE 'DEF%') OR CONTAINS(s.bodycopy,'DEF^100') OR (s.bodycopy LIKE 'DEF%') OR CONTAINS(s.headingText,'DEF^10') OR (s.headingText LIKE 'DEF%') OR CONTAINS(s.Author,'DEF^400') OR (s.Author LIKE 'DEF%') OR CONTAINS(s.headline,'DEF^2') OR (s.headline LIKE 'DEF%') OR CONTAINS(s.[jcr:title],'DEF') OR (s.[jcr:title] LIKE 'DEF%') OR CONTAINS(s.[cq:tags],'ABC^600') OR CONTAINS(s.blocktitle,'ABC^400') OR (s.blocktitle LIKE 'ABC%') OR CONTAINS(s.bodycopy,'ABC^100') OR (s.bodycopy LIKE 'ABC%') OR CONTAINS(s.headingText,'ABC^10') OR (s.headingText LIKE 'ABC%') OR CONTAINS(s.Author,'ABC^400') OR (s.Author LIKE 'ABC%') OR CONTAINS(s.headline,'ABC^2') OR (s.headline LIKE 'ABC%') OR CONTAINS(s.[jcr:title],'ABC') OR (s.[jcr:title] LIKE 'ABC%')) AND ( NOT [hideInSearch] IS NOT NULL) ORDER BY 'jcr:lastModified'

1] Can someone please validate if whatever we are doing is correct or not?

1 Accepted Solution

Avatar

Correct answer by
Level 9
6 Replies

Avatar

Level 9

Hi Jitendra,

Thank you for your reply.

1] So, the only way to validate if this is correct or not, would be to do multiple testing with this?

2] Also, do you have any references to any articles/posts which has a similar requirement to be met.

Avatar

Correct answer by
Level 9

@Askdctm,

I would recommend to go with full-text search and explore if that could solve your problem.

http://www.tothenew.com/blog/full-text-search-in-aem-using-query-builder/

https://docs.adobe.com/docs/en/cq/5-6-1/dam/customizing_and_extendingcq5dam/query_builder.html

--

Jitendra

Avatar

Community Advisor

Hi,

I tried executing query and saw some more results are also populating like 

1. If input "ABCsomething" this result also is displayed

2.Similarly "somethingDFE".

As per my observation your query is meeting your requirments and above pointers also.

Avatar

Level 9

Hi Korthivada,

Thank you for your reply.

If I understand correctly, you mean the below :

1] If I put "ABC DEF" into the search box and use query #2[the second query used in my first post], it will give pages which matches the keywords

a] ABC

b] DEF

c] ABC DEF

d] ABC something

e] something DEF

2] Is my understanding in pointer #1 above,correct?

Avatar

Level 9

Hi All,

1] Can you please confirm, if above is the expected behavior.

2] Also, is there any other way we can meet just our requirement.

Avatar

Community Advisor
        Hi , What I want to convey is if the input having a single word as ABCsomething without any spaces this is also displayed in result