Search related query | Community
Skip to main content
New Participant
January 4, 2016
Solved

Search related query

  • January 4, 2016
  • 6 replies
  • 1066 views

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?

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

@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

6 replies

Mani_kumar_
New Participant
January 4, 2016
        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
askdctmAuthor
New Participant
January 4, 2016

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.

askdctmAuthor
New Participant
January 4, 2016

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?

Mani_kumar_
New Participant
January 4, 2016

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.

Jitendra_S_Toma
Jitendra_S_TomaAccepted solution
New Participant
January 4, 2016
askdctmAuthor
New Participant
January 4, 2016

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.