solrsolarium

How to configure Solarium to use POST instead of GET Requests


im facing the problem that our uri's sent to solr (jetty) are getting to long, way over 9k bytes which exceeds the default limit by jetty.

the solution would be to switch from GET requests to POST requests because we do not want to increase the requestHeaderSize jetty can accept.

so while upgrading the project we also switched to solarium as php solr client. now the question is what is the correct way to set POST as default method or on a request basis and on what level does that happen? solr client or request or something else?

help is much appreciated.


Solution

  • You can use the bundled PostBigRequest plugin. It'll allow you to either use a limit before the request is switched to a POST request, or send all requests as POST requests. If you don't have a specific need to use GET requests (for example caching if you have a reverse proxy such as varnish present), you can switch all your requests to POST requests.

    // create a client instance and autoload the postbigrequest plugin
    $client = new Solarium\Client($config);
    $client->getPlugin('postbigrequest');