0 Replies Latest reply on Jun 27, 2013 3:59 AM by Anoop_Kumar

    SQL2 Query Clarification

    Anoop_Kumar

      Hi,

       

        We have search functionality in our application which runs a query similar to the one below:

       

      SELECT * FROM [cq:PageContent] as queryResult

      WHERE ISDESCENDANTNODE('/content/mysite')

      AND (CONTAINS(queryResult.*,'%searchWord%'))

      order by [jcr:score] desc

       

      The above query searches for the "searchWord" within all the nodes and properties of the pages.

      What we also see is that the match does not limit the search to the content of the page, it tries to match any property value even though it might not be displayed on the page like cq:tags, component names etc.

       

      Is there a way in which we can restrict the search to match only if the "searchWord" is present in the content of the page as a part of a text or title?

      I understand that we would need to replace queryResult.* with specific properties, but since each page in the website might have different properties with content, it would be difficult to write a query listing all the properties.

      Is there a better way of doing this?

       

      Thanks and Regards,
      Anoop Kumar