Uploaded image for project: 'CMS'
  1. CMS
  2. CMS-7822

[Solr] FO search failed when textfield contains double quote

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 4.0M13
    • None
    • Plugin : Search
    • None

      How to reproduce

      • Go on FO search service
      • In text field enter : ametys "enquête en ligne"

      The quote double are escaped twice into join query

      Caused by: org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://localhost:8983/solr: org.apache.solr.search.SyntaxError: Expected identifier at pos 59 str='{!join from=id to=contentIds v="full_fr:(ametys\ \\"enquête\ en\ ligne\\")"}'
      	at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:577)
      	at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:241)
      	at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:230)
      	at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:149)
      	at org.apache.solr.client.solrj.SolrClient.query(SolrClient.java:942)
      	at org.ametys.web.frontoffice.AbstractSearchGenerator.search(AbstractSearchGenerator.java:295)
      	at org.ametys.web.frontoffice.AbstractSearchGenerator.search(AbstractSearchGenerator.java:249)
      	at org.ametys.web.frontoffice.SearchGenerator.search(SearchGenerator.java:195)
      	at org.ametys.web.frontoffice.AbstractSearchGenerator.generate(AbstractSearchGenerator.java:209)
      	at org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.processXMLPipeline(AbstractProcessingPipeline.java:581)
      

          [CMS-7822] [Solr] FO search failed when textfield contains double quote

          solved in master branch, but FO search will probably be modified deeper in feature/search branch

          Simon Prieul (Inactive) added a comment - solved in master branch, but FO search will probably be modified deeper in feature/search branch

          Simon Prieul (Inactive) added a comment - - edited

          we have to pay attention to not introduce a regression to CMS-7815 and CMS-7790

          Simon Prieul (Inactive) added a comment - - edited we have to pay attention to not introduce a regression to CMS-7815 and CMS-7790

          The search text is escaped once into _addTextFieldQuery method of SearchGenerator : ClientUtils.escapeQueryChars(text)

          It is escaped one more time into FullTextQuery : StringQuery.escapeStringValue(_value);

          Then into PageContentQuery the quote are again escaped : _contentQuery.build().replace("\"", "\\\"")

          Certainly too much ...

          The executed Solr query is :

          Solr query: q=((full_fr:(ametys\ \"enquête\ en\ ligne\") OR {!join from=id to=contentIds v="full_fr:(ametys\ \\"enquête\ en\ ligne\\")"}))&fq=_documentType:"page" OR _documentType:"resource"&fq=site:www&fq=sitemap:fr&start=0&rows=2147483647&fl=*,score
          

          Laurence Aumeunier added a comment - The search text is escaped once into _addTextFieldQuery method of SearchGenerator : ClientUtils.escapeQueryChars(text) It is escaped one more time into FullTextQuery : StringQuery.escapeStringValue(_value); Then into PageContentQuery the quote are again escaped : _contentQuery.build().replace("\"", "\\\"") Certainly too much ... The executed Solr query is : Solr query: q=((full_fr:(ametys\ \"enquête\ en\ ligne\") OR {!join from=id to=contentIds v="full_fr:(ametys\ \\"enquête\ en\ ligne\\")"}))&fq=_documentType:"page" OR _documentType:"resource"&fq=site:www&fq=sitemap:fr&start=0&rows=2147483647&fl=*,score

            sprieul Simon Prieul (Inactive)
            laurence Laurence Aumeunier
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: