I'm trying to add new query listener with the SolR Config API. To do that, I POST the following JSON to the Config API endpoint of my SolR core :
{
"add-listener": {
"name": "listener1",
"class": "solr.QuerySenderListener",
"event": "newSearcher",
"queries": [{
"q": "any:whatever",
"rows": "10",
"start": "0"
}
]
}
}
This action populates the "configoverlay.json" file which overrides the standard solrconfig.xml. This file now looks like the following :
{
"listener": {
"listener1": {
"name": "listener1",
"class": "solr.QuerySenderListener",
"event": "newSearcher",
"queries": [{
"q": "any:whatever",
"rows": "10",
"start": "0"
}
]
}
}
}
For some reason, this structure doesn't seem to be OK for SolR. I get the following error in SolR logs :
null:java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to org.apache.solr.common.util.NamedList
at org.apache.solr.core.QuerySenderListener.newSearcher(QuerySenderListener.java:47)
at org.apache.solr.core.SolrCore$5.call(SolrCore.java:1835)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.solr.common.util.ExecutorUtil$MDCAwareThreadPoolExecutor$1.run(ExecutorUtil.java:210)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
And of course, the query associated to this event is therefore not executed as intended.
Apparently, the query format doesn't fit what SolR expects... I didn't find any example of updating or creating events in the SolR Config API documentation.
The problem must be related to the syntax of the parameters of the queries objects.
If you know how to format the json message to produce a proper listener, let me know !
In case it matters, I'm using SolR 5.3.1
p.s : The point of doing this via config API instead of solrconfig.xml is to be able to change the warming queries dynamically (to reflect configuration changes in our product which uses SolR for searching purposes).
Guillaume