Dear Wiki user, You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.
The "VelocityResponseWriter" page has been changed by SaschaSzott. http://wiki.apache.org/solr/VelocityResponseWriter?action=diff&rev1=21&rev2=22 -------------------------------------------------- = Introduction = - <!> Solr 1.4 <!> VelocityResponseWriter (aka [[Solritas]]) enables Solr to respond with content generated from [[http://velocity.apache.org|Velocity]] templates. Along with technologies like SolrJS, this makes Solr itself capable of driving sophisticated search interfaces without the need for an intermediate application server between the browser and Solr. @@ -9, +8 @@ See [[https://issues.apache.org/jira/browse/SOLR-620|SOLR-620]] for more information. = Instructions to use = - These steps will get you up and running for the examples below: - * Check out Solr trunk: svn co https://svn.apache.org/repos/asf/lucene/solr/trunk + * Check out Solr trunk: svn co https://svn.apache.org/repos/asf/lucene/solr/trunk - * Build Solr: ant clean example + * Build Solr: ant clean example - * Fire up Solr: cd example; java -Dsolr.solr.home=../contrib/velocity/src/main/solr/ -jar start.jar + * Fire up Solr: cd example; java -Dsolr.solr.home=../contrib/velocity/src/main/solr/ -jar start.jar - * Index sample docs: cd example/exampledocs; java -jar post.jar *.xml + * Index sample docs: cd example/exampledocs; java -jar post.jar *.xml - * Hit the examples below... + * Hit the examples below... = Sample Usage = - http://localhost:8983/solr/itas - Renders browse.vm from conf/velocity. Faceted navigation included. + . Renders browse.vm from conf/velocity. Faceted navigation included. - - http://localhost:8983/solr/itas?v.template.header=Custom%20Header + [[http://localhost:8983/solr/itas?v.template.header=Custom%20Header|http://localhost:8983/solr/itas?v.template.header=Custom%20Header]] + - Renders browse.vm, but overrides the header.vm from conf/velocity with the specified value. + . Renders browse.vm, but overrides the header.vm from conf/velocity with the specified value. http://localhost:8983/solr/itas?debugQuery=true - Renders browse.vm, adding in explanation views per hit, and a Velocity context dump at the end. + . Renders browse.vm, adding in explanation views per hit, and a Velocity context dump at the end. == Using the VelocityResponseWriter in Solr Core == - The VelocityResponseWriter is still a contrib component. In order to use it with the core distributions the following steps need to be followed: The following jars need to be copied from contrib/velocity/src/main/solr/lib/ to $SOLR_HOME/lib: @@ -55, +51 @@ {{{ <queryResponseWriter name="velocity" class="org.apache.solr.request.VelocityResponseWriter"/> }}} - Set up a RequestHandler in solrconfig.xml: {{{ @@ -63, +58 @@ <lst name="defaults"> <str name="v.template">browse</str> <str name="v.properties">velocity.properties</str> + <str name="v.contentType">text/xml;charset=UTF-8</str> <str name="title">Solritas</str> <str name="wt">velocity</str> @@ -82, +78 @@ <!--</lst>--> </requestHandler> }}} - Copy the .../contrib/velocity/src/main/solr/velocity directory to $SOLR_HOME/conf/. This directory contains the Velocity templates that will be needed by the VelocityResponseWriter, and also a style sheet, main.css. The templates and style sheet can be edited to customize the display. == Options == - * {{{v.template}}}: template name to use, without the .vm suffix. If not specified, "default"[.vm] will be used. * {{{v.template.<name>}}}: overrides a file system template * {{{debugQuery}}}: if true, default view displays explanations for each hit and additional debugging information in the footer. * {{{v.json}}}: Escapes and wraps Velocity generated response with v.json parameter as a JavaScript function. - * {{{v.layout}}}: Template name that wraps main template (v.template). Main template renders to a $content that can be used in layout template. + * {{{v.layout}}}: Template name that wraps main template (v.template). Main template renders to a $content that can be used in layout template. - * {{{v.base_dir}}}: overwrites default template load path (conf/velocity/). + * {{{v.base_dir}}}: overwrites default template load path (conf/velocity/). - * {{{v.properties}}}: specifies a velocity properties file (velocity.propeties) to be applied. + * {{{v.properties}}}: specifies a velocity properties file (velocity.propeties) to be applied. + * {{{v.contentType}}}: sets the value of the HTTP request's Content-Type header (in case html pages should be UTF-8 (instead of ISO-8859-1) encoded, make sure you set this option to {{{text/xml;charset=UTF-8}}}) + == Velocity Context == - * {{{esc}}}: a Velocity [[http://velocity.apache.org/tools/releases/1.4/generic/EscapeTool.html|EscapeTool]] instance * {{{date}}}: a Velocity [[http://velocity.apache.org/tools/releases/1.4/javadoc/org/apache/velocity/tools/generic/ComparisonDateTool.html|ComparisonDateTool]] instance * {{{list}}}: a Velocity [[http://velocity.apache.org/tools/releases/1.4/javadoc/org/apache/velocity/tools/generic/ListTool.html|ListTool]] instance @@ -108, +103 @@ * {{{sort}}}: a Velocity [[http://velocity.apache.org/tools/releases/1.4/javadoc/org/apache/velocity/tools/generic/SortTool.html|SortTool]] instance == TODO == - * Ajax suggest * Integrate/adapt to SolrJS @@ -122, +116 @@ * Work on "dist" target so this works easily with a nightly build. * Make Velocity tools and engine configuration pluggable + ---- CategoryQueryResponseWriter
