Solr Delay Component
Solr Delay Component
Join the DZone community and get the full member experience.Join For Free
A true open source, API-first CMS — giving you the power to think outside the webpage. Try it for free.
First of all, why would you want to slow Solr down? After all, it’s great speed is one of the main reasons it’s become so popular. Well, I need to slow Solr down for testing load balancing timeouts / failover and to test parallel execution. Both are hard to do with response times well below a second. There are some tricks possible using inefficient queries, however that’s not very consistent.
So, I’ve made a simple component that allows you to slow Solr down for with an exact amount of time using the query string. When the component is enabled you can simple add your delay (in millisec) to the request like this: &delay=5000
Maybe this is useful to more people, so I’ve placed it on GitHub. Here are the steps to use it:
- Go to the GitHub project page https://github.com/basdenooijer/raspberry-solr-plugins and download the project.
- In the build dir of the project is one jar file. Place this in the instanceDir of your Solr core, in a folder called ‘lib’. This folder may not exist yet, in that case create it. For a Solr example install the directory is: /example/solr/lib
- Add the two snippets below to your solrconfig.xml (I’m assuming a default solrconfig.xml, otherwise you might need to adjust the configs)
- Restart Solr
- Test it by adding a delay param to your request. For instance:
This should delay the query by one second, you should also be able to see this in the debug output. The delay param is in milliseconds. No param or a value of 0 disables the delay.
These are the two snippets you need to add to your solrconfig.xml:
Add this inside the requestHandler definition that is named “search”:
<arr name="last-components"> <str>delay</str> </arr>
Outside the requestHandler definition add this:
<searchComponent name="delay" class="nl.raspberry.solr.DelayComponent"> </searchComponent>
Important warning: this component is intended purely for testing purposes. It’s not advised to enable this component on a production environment. First of all it’s useless, in production you should not be testing. But it can also easily be abused to flood the server with lots of queries with a big delay.
Opinions expressed by DZone contributors are their own.