How to search utf8 wordings in Magento Enterprise Edition with Solr?

April 30, 2013 20:20
Tags: , , ,

Magento Enterprise Edition has an option that can use the Apache Solr for the indexing and searching engine. For English searching is working like a charm, however, not working well with UTF8 encoding like Traditional Chinese.

I’ve found that it is because the class “Apache_Solr_Service” sends the search request to Solr with the content-type “application/x-www-form-urlencoded”. This content type doesn’t specific the charset is UTF8, and sends the wrong encoded search text to Solr. At the end, for sure that unexpected result will be returned.

It’s very easy to fix this problem. First copy the file “lib/Apache/Solr/Service.php” to “app/code/local/Apache/Solr/Service.php”, then modify “app/code/local/Apache/Solr/Service.php” line 968 from:

    return $this->_sendRawPost($this->_searchUrl, $queryString, FALSE, 'application/x-www-form-urlencoded');


    return $this->_sendRawPost($this->_searchUrl, $queryString, FALSE, 'application/x-www-form-urlencoded; charset=UTF-8');

That is, great?


4 Responses to “How to search utf8 wordings in Magento Enterprise Edition with Solr?”

  1. Good information to search in magento. Thanks for sharing this. I was wondering how does no one is searching for this kind of blog. Thanks a lot it helped me at last minute.

  2. Awesome guide for Magento. I really appreciate your efforts and I am waiting for your next post thank you once again.

  3. Thanks I have got better understanding with the codings here. this will help so many beginners

  4. Many thanks for this post, which fixed my problem searching for umlauts!