Search code examples
urlencodegoogle-search-appliance

gsa double encoding partialfields


I'm trying to build a correct query string for the GSA with partialfiels that contains the filters selected by users. Looking at the google documentation I have to double encode values. I write this simple function but if I select a filter that contains special chars (example: foo's pen) it doesn't work and GSA returns me 0 results.

protected function myUrlEncode($str) {
    $str = rawurlencode($str);
    $replacements = array('%2D', '%2E', '%7E');
    $entities = array('-','.','~');
    $str = str_replace($entities, $replacements, $str);
    return urlencode($str);
}

this function returns foo%2527s%2520pen that I use in the url: &partialfields=metaname:foo%2527s%2520pen


Solution

  • Here the probelm is due to special character in your metadata content/value. Since you are using partialfields request parameter, try to hit GSA with partialfields=metaname:foo (encode it before firing the query). This should resolve your issue.

    I had similar issue long back then I modified content sources to remove special characters from metadata name and content.

    Hope it helps.

    Regards,

    Mohan