Search related query
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?