Change request method to POST for queries
- HaikoGParticipant4 years, 7 months ago #16811
Hi,
We have some large queries due to category exclusions for the default product searches. This means we dynamically add a lot of categories to the query before the query is executed. This causes the query to exceed the URI length limit and throws an error.
My guess is that this query uses a GET method as these are limited by length. Can you tell me if there is a way to change this to a POST request? and if so, how?Uncaught Exception: Solr HTTP error: OK (414)
<h1>Bad Message 414</h1>reason: URI Too Long
in /mnt/datadrive/public_html/testshop.switch.nl/wp-content/plugins/wpsolr-pro/wpsolr/core/vendor/solarium/solarium/library/Solarium/Core/Query/Result/Result.php on line 106
wpsolrKeymaster4 years, 7 months ago #16812You mean something like that? https://solarium.readthedocs.io/en/latest/plugins/#postbigrequest-plugin
HaikoGParticipant4 years, 7 months ago #16814Thanks for the quick reply
I think the postbigrequest-plugin is what we’re after, but I haven’t figured out how to activate it yet.getPlugin(‘postbigrequest’);
According to the documentation that should be called on the solarium client, but the obj from get_solr_client does not recognize the function$solr_client = WPSOLR_Service_Container::get_solr_client( false );
any ideas?
wpsolrKeymaster4 years, 7 months ago #16815Try this one:
add_action( 'init', function () { if ( defined( 'WPSOLR_PLUGIN_SHORT_NAME' ) ) { /** * * Set post method on Solarium client. * * @param array $parameters * */ function wpsolr_solarium_query_set_post_method( $parameters ) { /* @var WPSOLR_AbstractSearchClient $search_engine_client */ $client = $parameters[ WPSOLR_Events::WPSOLR_ACTION_SOLARIUM_QUERY__PARAM_SOLARIUM_CLIENT ]; $client->get_search_engine_client()->getPlugin('postbigrequest'); } // Catch Solarium query before calling Solr add_action( WpSolrFilters::WPSOLR_ACTION_SOLARIUM_QUERY, 'wpsolr_solarium_query_set_post_method', 10, 1 ); } } );
You must be logged in to reply to this topic.