4 Replies Latest reply on Apr 15, 2013 4:49 AM by tygeBSL

    Search pages using localized translated tag titles:

    SNEDAS

      ENV: CQ5.4

       

      Suppose I have a Tag created with the name 'XYZ' and I have translated localized titles for the same tag as:

      §  EN: ABC

      • DE: DEF
      • FR: GHI
      • ES: JKL

      Now if an user would search for 'XYZ' he would always find pages which are tagged with the above tag regardless which language tree she/he is browsing. But if the user is search for 'ABC' in the English language tree, no result is displayed. So the requirement is to include the localized translated tag titles will be part of the search. Moreover an user in the EN tree would find a result if he enters 'XYZ' or entered 'ABC', but no result would be found if the search term is 'DEF' as "DEF' is for DE tree.

       

      Any help/pointers on this would be appreciated.

       

        • 1. Re: Search pages using localized translated tag titles:
          sameer bh

          Hi,

           

          OOTB search component does not consider tag titles while searching the content. You can verify this by looking at the generated xpath.

           

          The main problem is to find the actual tag given it's title(even localized one) , name or ID. Also something like following does not seem to work though API suggests that given a title, the tag should be resolvable.

          tag = tagManager.resolveByTitle(searchTag);

           

          I would suggest you find try to find out the actual tag by using the querybuilder. Depending on the langauge you need to find the content in, you will have to search the tag below /etc/tag node. So for example you want to search in the french branch then you need to find the tag with property as jcr:title.fr and value as GHI(your example).

           

          Once you get the hold of tag(ID or Name), you can then easily find the content using either querybuilder or tagManager.find() api.

           

          I will also give it a try and get back to you.

           

          Regards,

          Sameer

          • 2. Re: Search pages using localized translated tag titles:
            sameer bh Level 1

            Hi,

             

            I tried querybuilder debugger to quickly find the results. You may need to use Querybuilder api and java class example elaborated at http://dev.day.com/docs/en/cq/current/dam/customizing_and_extendingcq5dam/query_builder.ht ml

             

            So I first try to find the tag id given the localized title of the tag using following xpath expression:

             

            type=cq:tag

            orderby=@jcr:content/cq:lastModified

            path=/etc/tags

            property=jcr:title.fr

            property.value=GHI

             

            This resultset will hold the actual tag used. Once you know the tag you again need to use querybuilder and form a new query dynamically. I used the following expression to find the pages.

             

            type=cq:Page

            group.p.or=true

            group.1_tagid=marketing:interest/product

            group.1_tagid.property=jcr:content/cq:tags

            group.2_tagid=aaa:ddd

            group.2_tagid.property=jcr:content/cq:tags

             

            Above you need to pass the tag ids(here I assume mutiple tags for a given localized title. In case the author makes sure that no two titles have the same value, you do not need group clauses).

             

            Regards,

            Sameer

            • 3. Re: Search pages using localized translated tag titles:
              SNEDAS Level 1

              Thanks Sameer.

               

              I have tried the solution and it worked just fine.

              One question on this, do you think there will be any performance issue since 2 queries are getting executed, one for the tag and the other one for the actual content search.

              • 4. Re: Search pages using localized translated tag titles:
                tygeBSL

                I think you can cache this in a service and so as tags won't change so often and should not be millions, it can be cached, just update the cache according to jcr event eventually after it get initialized from existing content.