Solr answer with an error when fq parameters has fields with white spaces

Issue #31 new
Former user created an issue

I have changed in my local solr.js the following to solve the problem. The following modification means for managing white spaces inside fields for fq parameters. After encodeURI fq=Part1 part2 becomes fq=Part1%20part2 but solr answer with error. Then white spaces must start with a backslash such that fq=Part1\%20part2

Best regards

/**
 * Get the fully specified Solr query URL.
 */
self.getSolrQueryUrl = function() {
    /*The following modification means for managing white spaces inside fields for fq parameters. After encodeURI fq=Part1 part2 becomes 
       fq=Part1%20part2 but solr answer with error. Then white spaces must start with a backslash such that fq=Part1\%20part2*/
    var t=self.solr + "/select?" + encodeURI(self.getQuery());
    return t.replace(/fq=(\w+)%20/g, "fq=$1\\%20" )
    //return self.solr + "/select?" + encodeURI(self.getQuery());
};

Comments (1)

  1. Edgardo Ambrosi

    I have upgraded this issue because white spaces can appear multiple times into fields, so the above method as been changed with the following:

    /**
     * Get the fully specified Solr query URL.
     */
    self.getSolrQueryUrl = function() {
        /*EDGARDO:The following modification means for managing white spaces inside fields for fq parameters. After encodeURI fq=Part1 part2 becomes 
           fq=Part1%20part2 but solr answer with error. Then white spaces must start with a backslash such that fq=Part1\%20part2*/
        var t=self.solr + "/select?" + encodeURI(self.getQuery());
        var g=t.split("&")
        $.each(g,function(i,e){
            var f=e.match(/^fq=/)    
            if(f!=null && f.length==1) {
                var r=e.replace(/%20/g, "\\%20" )
                g[i]=r
            }    
        })
        return g.join("&")
        //return self.solr + "/select?" + encodeURI(self.getQuery());
    };
    
  2. Log in to comment