You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by henri <he...@laposte.net> on 2012/04/04 10:29:44 UTC

Re: UTF-8 encoding

I have finally solved my problem!!

Did the following:

added two lines in the /browse requestHandler
       <str name="v.properties">velocity.properties</str>
       <str name="v.contentType">text/html;charset=UTF-8</str>

Moved velocity.properties from solr/conf/velocity to solr/conf

Not being an expert, I am not 100% sure this is the "best" solution, and
where and how it should be documented in the solr/velocity package. I will
leave this doc update to afficionados.

Cheers to all,
Henri

--
View this message in context: http://lucene.472066.n3.nabble.com/UTF-8-encoding-tp3867885p3883485.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: UTF-8 encoding

Posted by Erik Hatcher <er...@gmail.com>.
Apologies for not replying sooner on this thread, I just noticed it today...

To add insight into where velocity.properties can reside, it is used this way in VelocityResponseWriter.java:

    SolrVelocityResourceLoader resourceLoader =
        new SolrVelocityResourceLoader(request.getCore().getSolrConfig().getResourceLoader());
    String propFile = request.getParams().get("v.properties");
          is = resourceLoader.getResourceStream(propFile);
          Properties props = new Properties();
          props.load(is);
          engine.init(props);

SolrVelocityResourceLoader is a pass-through hook to Solr's ResourceLoader, allowing it to load resources from:

  /** Opens any resource by its name.
   * By default, this will look in multiple locations to load the resource:
   * $configDir/$resource (if resource is not absolute)
   * $CWD/$resource
   * otherwise, it will look for it in any jar accessible through the class loader.
   * Override this method to customize loading resources.
   *@return the stream for the named resource
   */
  public InputStream openResource(String resource)

So that file could conceivably live in many places, but conf/ is where I'd put it.

I've just updated the wiki documentation to say this instead:

v.properties: specifies a Velocity properties file to be applied, found using the Solr resource loader mechanism. If not specified, no .properties file is loaded. Example: v.properties=velocity.properties where velocity.properties can be found using Solr's resource loader mechanism, for example in the conf/ directory (not conf/velocity which is for templates only). The .properties file could also be located inside a JAR in the lib/ directory, or other locations.

Feel free to modify that if it needs improving.

Thanks,
	Erik


On Apr 4, 2012, at 04:29 , henri wrote:

> I have finally solved my problem!!
> 
> Did the following:
> 
> added two lines in the /browse requestHandler
>       <str name="v.properties">velocity.properties</str>
>       <str name="v.contentType">text/html;charset=UTF-8</str>
> 
> Moved velocity.properties from solr/conf/velocity to solr/conf
> 
> Not being an expert, I am not 100% sure this is the "best" solution, and
> where and how it should be documented in the solr/velocity package. I will
> leave this doc update to afficionados.
> 
> Cheers to all,
> Henri
> 
> --
> View this message in context: http://lucene.472066.n3.nabble.com/UTF-8-encoding-tp3867885p3883485.html
> Sent from the Solr - User mailing list archive at Nabble.com.