[
https://issues.apache.org/jira/browse/SOLR-7915?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14997371#comment-14997371
]
Erik Hatcher commented on SOLR-7915:
------------------------------------
I just tested this, thanks for asking [~arafalov] (on a clean branch_5x
checkout) -
{code}
bin/solr create -c files -d example/files
bin/post -c files ~/Documents/TestDocs
curl http://localhost:8983/solr/files/config -H 'Content-type:application/json'
-d '{
"add-queryresponsewriter":{
"name":"celeritas",
"class":"solr.VelocityResponseWriter",
"params.resource.loader.enabled": "true",
"tools":{
"just_a_string":"java.lang.String"
}
}
}'
{code}
It modifies configoverlay.json with:
{code}
{"queryResponseWriter":{"celeritas":{
"name":"celeritas",
"class":"solr.VelocityResponseWriter",
"params.resource.loader.enabled":"true",
"tools":{"just_a_string":"java.lang.String"}}}}
{code}
And that behaves as expected leveraging the new tool,
http://localhost:8983/solr/files/select?q=*:*&wt=celeritas&v.template=foo&v.template.foo=$response.results.numFound:%20(and%20btw:%20just_a_string.class%20=%20$just_a_string.class)
responds with:
{code}
328: (and btw: just_a_string.class = class java.lang.String)
{code}
> Provide pluggable Velocity context tool facility
> ------------------------------------------------
>
> Key: SOLR-7915
> URL: https://issues.apache.org/jira/browse/SOLR-7915
> Project: Solr
> Issue Type: Improvement
> Components: contrib - Velocity
> Affects Versions: 5.3
> Reporter: Erik Hatcher
> Assignee: Erik Hatcher
> Fix For: 5.4, Trunk
>
> Attachments: SOLR-7915.patch
>
>
> Currently the "tools" placed in the VelocityResponseWriter's context are
> hard-coded. It can be very handy to be able to plug in 3rd party or custom
> tools (just any ol' Java object a "tool" can be).
> Here's a list of the currently hard-coded tools:
> https://github.com/apache/lucene-solr/blob/trunk/solr/contrib/velocity/src/java/org/apache/solr/response/VelocityResponseWriter.java#L189-L199
> ----
> The implementation committed allows custom tools to be registered as part of
> the VelocityResponseWriter definition in solrconfig.xml like this:
> {code}
> <queryResponseWriter name="velocityWithCustomTools"
> class="solr.VelocityResponseWriter">
> <lst name="tools">
> <str name="mytool">com.example.solr.velocity.MyTool</str>
> <!-- ... -->
> </lst>
> </queryResponseWriter>
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]