I was talking to a coworker yesterday who has recently started using hte
DisMax handler ... she was annoyed that the "fq" param could only be
specified once (which was changed as part of the SimpleFacet patch so
that's all good) but she was also annoyed that having an "fq" default in
the solrconfig was completely overridden by an "fq" in the URL --
something that's still true with the recent changes.  There's currently no
way to specify some params in the config that can be "added to" by the
params in the URL.

Generalized support for being able to say "The default value list for
param P is A B C, and at query time I want to add X and Y and eliminate B"
seems like a a really hard problem to solve, but i was thinking of a
simpler approach that might still achieve the more common case where we
want values specified in a config to allways be "appended" to multivalue
params using somehting like this psuedo-java...

public class MergedParams extends DefaultSolrParams {
  public String[] getParams(String param) {
    return params.getParams(param).addAll(defaults.getParams(param));
  }
}

and request handlers could support this using something like...

  <requestHandler name="dismax" class="solr.DisMaxRequestHandler" >
    <lst name="appended">
      <str name="fq">inStock:true</str>
    </lst>
    <lst name="default">
      <str name="fq">color:red</str>
      <str name="fq">price:[* TO 100]</str>
    </lst>
 </requestHandler>

...with the existing DefaultSolrParams wrapped in an MergedParams using
the "appended" section.  Now a request for "/select/?qt=dismax&q=foo"
would get all three "fqs" applied, but a request for
"/select/?qt=dismax&q=foo&fq=color:blue" would only have two filters
applied (must be inStock, must be blue) ... this would be particularly
handy when trying to use "fq" to globally partition your index, as well as
provide "drill down" filtering options.

The same MergedParams could even support a <lst name="prepended"> set
of params which would work exactly the same for multivalue params (like
fq), but would allow the config to dictate the values of single value
params (like "rows", "facet") so thatthey can't be overidden at query
time.


What do you guys think?


-Hoss

Reply via email to