title: How to set up SOLR parameter substitution in solrconfig.xml
body: <p>This is my first question at stackoverflow so apologies in advance if I break any rules but I did study them and also made sure this isn't a duplicate question.</p>
  
  <p>So, according to this <a href="http://yonik.com/solr-query-parameter-substitution/" rel="nofollow">http://yonik.com/solr-query-parameter-substitution/</a> one can set up a search handler in solrconfig in a way that the </p>
  
  <blockquote>
    <p>request handler defaults, appends, and invariants configured for the
    handler may reference request parameters</p>
  </blockquote>
  
  <p>I have the following query which works just fine with curl</p>
  
  <pre><code>curl http://localhost:7997/solr/vb_popbio/select -d 'q=*:*&amp;fq=bundle:pop_sample_phenotype AND phenotype_type_s:"insecticide%20resistance"
  &amp;rows=0&amp;wt=json&amp;json.nl=map&amp;indent=true
  &amp;fq=phenotype_value_type_s:${PFIELD}&amp;
  &amp;PGAP=5&amp;PSTART=0&amp;PEND=101&amp;PFIELD="mortality rate"&amp;
  json.facet = {
              pmean: "avg(phenotype_value_f)",
              pperc: "percentile(phenotype_value_f,5,25,50,75,95)",
              pmin: "min(phenotype_value_f)",
              pmax: "max(phenotype_value_f)",
              denplot : {
                  type : range,
                  field : phenotype_value_f,
                  gap : ${PGAP:0.1},
                  start: ${PSTART:0},
                  end: ${PEND:1}
              }
      }'
  </code></pre>
  
  <p>I have translated this query to a search handler configuration in solrconfig.xml so a user only has to provide the PFIELD, PGAP, PSTART and PEND parameters. Here's how the configuration for the handler looks </p>
  
  <pre><code>     &lt;!--A request handler to serve data for violin plots (limited to IR assays)--&gt;
  &lt;requestHandler name="/irViolin" class="solr.SearchHandler"&gt;
      &lt;!-- default values for query parameters can be specified, these
           will be overridden by parameters in the request
        --&gt;
      &lt;lst name="defaults"&gt;
          &lt;str name="echoParams"&gt;explicit&lt;/str&gt;
          &lt;int name="rows"&gt;0&lt;/int&gt;
          &lt;str name="df"&gt;text&lt;/str&gt;
          &lt;str name="wt"&gt;json&lt;/str&gt;
          &lt;str name="json.nl"&gt;map&lt;/str&gt;
          &lt;str name="json.facet"&gt;{
              pmean: "avg(phenotype_value_f)",
              pperc: "percentile(phenotype_value_f,5,25,50,75,95)",
              pmin: "min(phenotype_value_f)",
              pmax: "max(phenotype_value_f)",
              denplot : {
              type : range,
              field : phenotype_value_f,
              gap: ${PGAP:0.1},
              start: ${PSTART:0},
              end: ${PEND:1}
              }
              }
          &lt;/str&gt;
      &lt;/lst&gt;
      &lt;lst name="appends"&gt;
          &lt;str name="fq"&gt;bundle:pop_sample_phenotype&lt;/str&gt;
          &lt;str name="fq"&gt;phenotype_type_s:"insecticide resistance"&lt;/str&gt;
          &lt;str name="fq"&gt;has_geodata:true&lt;/str&gt;
          &lt;str name="fq"&gt;phenotype_value_type_s:${PFIELD:"mortality rate"}&lt;/str&gt;
  
      &lt;/lst&gt;
      &lt;lst name="invariants"&gt;
      &lt;/lst&gt;
  
  &lt;/requestHandler&gt;
  </code></pre>
  
  <p>Notice that I provided default values for all the parameters otherwise SOLR will fail to load the configuration. The problem is that using a query like this</p>
  
  <pre><code>curl http://localhost:7997/solr/vb_popbio/irViolin?q=*:*&amp;
      &amp;PGAP=5&amp;PSTART=0&amp;PEND=101&amp;PFIELD="mortality rate"
  </code></pre>
  
  <p>is not working. SOLR will read the request parameters fine (I can see them on the debug output) but will ignore them and use the default values in the configuration instead.</p>
  
  <p>SOLR version is 5.2.1.</p>
  
  <p>I tried moving the configuration parameters to either defaults, appends or invariants but nothing is working. After researching this for the past 2 days I'm almost ready to give up and just build the whole query on-the-fly instead.</p>
  
  <p>Any help will be greatly appreciated.</p>
  
  <p>Many thanks</p>