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 Matt Work Coarr <ma...@gmail.com> on 2016/09/20 15:17:46 UTC

problem setting default params for /browse (velocity) queries

Good morning. I'm attempting to set some default query parameters via
solrconfig.xml but they are not taking effect.  I'm using the /browse
interface (e.g. velocity templates).

To keep it simple, let's start with "fl".  When I specify fl as a url
parameter, it does take effect.  But when I put it in solrconfig.xml, it's
not being used.

Right now, I'm putting this in a new init params element:

<initParams name="myParams">
  <lst name="defaults">
    <str name="fl">field1,field2,field3</str>
  </lst>
</initParams>


Then I tell the /browse request handler to add it to the list of useParams
(I've tried the beginning and end of the list):

<requestHandler name="/browse" class="solr.SearchHandler"
useParams="query,facets,velocity,browse,myParams">

I have also tried adding "useParams=myParams" in the url.

FYI, I have been including wt=xml in my url so that I eliminate the
possibility that the velocity templates are causing a problem.

Any ideas?

Thanks!
Matt

Re: problem setting default params for /browse (velocity) queries

Posted by Erik Hatcher <er...@gmail.com>.
> On Sep 20, 2016, at 5:04 PM, Matt Work Coarr <ma...@gmail.com> wrote:
> 
> It would be nice to have a link to that films example in the cwiki "Request
> Parameters API" page.

Done (put at the end).

> 
> Erik H, in your Lucidworks blog post, what is the meaning of the empty
> string keyed entries in each of the param sets?
> 
> "":{"v":0}

It’s an internal detail to the params serialization - some kind of version number for internal use.   The idea being that all operations and visibility of the params should be through the API rather than looking at that JSON file. 

	Erik


Re: problem setting default params for /browse (velocity) queries

Posted by Matt Work Coarr <ma...@gmail.com>.
It would be nice to have a link to that films example in the cwiki "Request
Parameters API" page.

Erik H, in your Lucidworks blog post, what is the meaning of the empty
string keyed entries in each of the param sets?

"":{"v":0}


Matt

Re: problem setting default params for /browse (velocity) queries

Posted by Erik Hatcher <er...@gmail.com>.
And for the curious, there’s examples of this sort of thing here… https://github.com/apache/lucene-solr/tree/master/solr/example/films <https://github.com/apache/lucene-solr/tree/master/solr/example/films>

This is one for Alexandre to take note of ;)   #solr_examples_protips (that admittedly could be documented better somewhere no doubt)

	Erik


> On Sep 20, 2016, at 3:31 PM, Matt Work Coarr <ma...@gmail.com> wrote:
> 
> Awesome! Thanks Erik and Erick!!
> 
> To close the loop on this, I was able to create a paramset via the rest api
> and then use it in a query via ?paramSet=myParams and it's working!!
> 
> Hopefully this information will help someone else...
> 
> My dataset has some text fields that should be used in more-like-this and
> it has some machine learning classifier score fields that vary from 0..1
> that I want to be able to do facets over different scores.
> 
> Here's the rest call to create my paramset:
> 
> export SOLR_BASE=http://myserver.mycompany.com:8983/solr
> export CORE=mycore
> 
> curl "$SOLR_BASE/$CORE/config/params" -H 'Content-type:application/json'
> -d '{
>  "update":{
>    "myParams":{
>      "rows":"5",
>      "facet": "on",
>      "facet.range":
> ["classificationfield1","classificationfield2","classificationfield3"],
>      "facet.range.start": "0.5",
>      "facet.range.end": "1.0",
>      "facet.range.gap": "0.1",
>      "facet.range.other" : "all",
>      "fl":
> "title,textfield1,textfield2,classificationfield1,classificationfield2,classificationfield3,score",
>      "mlt": "on",
>      "mlt.fl": "textfield1,textfield2",
>      "df":"_text_"}}
> }'
> 
> 
> Then I needed to add this new paramset to the *END* of the list in the
> requestHandler's useParams attribute:
> 
> <requestHandler name="/browse" class="solr.SearchHandler"
> useParams="query,facets,velocity,browse,myParams">
> 
> 
> A few wiki pages that I found useful...
> 
>   - "Request Parameters API":
>      -
>      https://cwiki.apache.org/confluence/display/solr/Request+Parameters+API
>   - "InitParms in SolrConfig"
>      -
>      https://cwiki.apache.org/confluence/display/solr/InitParams+in+SolrConfig
>      - "Config API"
>      - https://cwiki.apache.org/confluence/display/solr/Config+API
> 
> Matt


Re: problem setting default params for /browse (velocity) queries

Posted by Matt Work Coarr <ma...@gmail.com>.
Awesome! Thanks Erik and Erick!!

To close the loop on this, I was able to create a paramset via the rest api
and then use it in a query via ?paramSet=myParams and it's working!!

Hopefully this information will help someone else...

My dataset has some text fields that should be used in more-like-this and
it has some machine learning classifier score fields that vary from 0..1
that I want to be able to do facets over different scores.

Here's the rest call to create my paramset:

export SOLR_BASE=http://myserver.mycompany.com:8983/solr
export CORE=mycore

curl "$SOLR_BASE/$CORE/config/params" -H 'Content-type:application/json'
 -d '{
  "update":{
    "myParams":{
      "rows":"5",
      "facet": "on",
      "facet.range":
["classificationfield1","classificationfield2","classificationfield3"],
      "facet.range.start": "0.5",
      "facet.range.end": "1.0",
      "facet.range.gap": "0.1",
      "facet.range.other" : "all",
      "fl":
"title,textfield1,textfield2,classificationfield1,classificationfield2,classificationfield3,score",
      "mlt": "on",
      "mlt.fl": "textfield1,textfield2",
      "df":"_text_"}}
}'


Then I needed to add this new paramset to the *END* of the list in the
requestHandler's useParams attribute:

<requestHandler name="/browse" class="solr.SearchHandler"
useParams="query,facets,velocity,browse,myParams">


A few wiki pages that I found useful...

   - "Request Parameters API":
      -
      https://cwiki.apache.org/confluence/display/solr/Request+Parameters+API
   - "InitParms in SolrConfig"
      -
      https://cwiki.apache.org/confluence/display/solr/InitParams+in+SolrConfig
      - "Config API"
      - https://cwiki.apache.org/confluence/display/solr/Config+API

Matt

Re: problem setting default params for /browse (velocity) queries

Posted by Erik Hatcher <er...@gmail.com>.
Matt -

Those params (query, facets, and velocity) are defined in params.json as Erick mentioned.  See here:

    https://github.com/apache/lucene-solr/blob/master/solr/server/solr/configsets/data_driven_schema_configs/conf/params.json <https://github.com/apache/lucene-solr/blob/master/solr/server/solr/configsets/data_driven_schema_configs/conf/params.json>

I did a bit explaining of this here - https://lucidworks.com/blog/2015/12/08/browse-new-improved-solr-5/ <https://lucidworks.com/blog/2015/12/08/browse-new-improved-solr-5/>

Hope that helps.

	Erik


> On Sep 20, 2016, at 1:38 PM, Matt Work Coarr <ma...@gmail.com> wrote:
> 
> Thanks Erick.
> 
> The pre-existing request handler for /browse (the velocity template driven
> interface) already had this:
> 
> <requestHandler name="/browse" class="solr.SearchHandler"
> useParams="query,facets,velocity,browse">
> 
> I just added an entry for "myParams" and added the initParams element in
> solrconfig.xml.
> 
> I also tried adding a initParam with a path of /browse (similar to how the
> existing initParams elements were setup).
> 
> I was wondering where these param set on the /browse event handler were
> coming from.  Now that I know to look for params.json, I see a copy in my
> core's conf directory and it has "query", "facets", and "velocity" defined.
> 
> I'm going to try setting via the parameters api and see what happens...
> 
> Thanks for the pointers.
> 
> Matt


Re: problem setting default params for /browse (velocity) queries

Posted by Matt Work Coarr <ma...@gmail.com>.
Thanks Erick.

The pre-existing request handler for /browse (the velocity template driven
interface) already had this:

<requestHandler name="/browse" class="solr.SearchHandler"
useParams="query,facets,velocity,browse">

I just added an entry for "myParams" and added the initParams element in
solrconfig.xml.

I also tried adding a initParam with a path of /browse (similar to how the
existing initParams elements were setup).

I was wondering where these param set on the /browse event handler were
coming from.  Now that I know to look for params.json, I see a copy in my
core's conf directory and it has "query", "facets", and "velocity" defined.

I'm going to try setting via the parameters api and see what happens...

Thanks for the pointers.

Matt

Re: problem setting default params for /browse (velocity) queries

Posted by Erick Erickson <er...@gmail.com>.
I'm not entirely sure about this, but I think you're mixing up
useParams and initParams.

If I'm reading the docs correctly, useParams is used in conjunction
with the "Request
Parameters API" and whatever you're setting is stored in a separate
file (params.json),
not solrconfig.xml.

This is separate from the initParams which is all internal to
solroconfig.xml. I _think_
you'll be fine if you substitute "initParams" for "useParms" in your
requestHandler definition.

WARNING: This isn't really code I've used much, so this may be totally off base.

Best
Erick

On Tue, Sep 20, 2016 at 8:17 AM, Matt Work Coarr
<ma...@gmail.com> wrote:
> Good morning. I'm attempting to set some default query parameters via
> solrconfig.xml but they are not taking effect.  I'm using the /browse
> interface (e.g. velocity templates).
>
> To keep it simple, let's start with "fl".  When I specify fl as a url
> parameter, it does take effect.  But when I put it in solrconfig.xml, it's
> not being used.
>
> Right now, I'm putting this in a new init params element:
>
> <initParams name="myParams">
>   <lst name="defaults">
>     <str name="fl">field1,field2,field3</str>
>   </lst>
> </initParams>
>
>
> Then I tell the /browse request handler to add it to the list of useParams
> (I've tried the beginning and end of the list):
>
> <requestHandler name="/browse" class="solr.SearchHandler"
> useParams="query,facets,velocity,browse,myParams">
>
> I have also tried adding "useParams=myParams" in the url.
>
> FYI, I have been including wt=xml in my url so that I eliminate the
> possibility that the velocity templates are causing a problem.
>
> Any ideas?
>
> Thanks!
> Matt