i've run into a weird little oddity while working on SOLR-258 ... the
start/end/gap params need to be required, but i want it to be possible to
use "generaic"values for them even while vaceting over multiple fields,
ie this should work and use the start/end/gap values for both the birth
and death fields...
facet=true&facet.date=birth&facet.date=death&facet.date.start=NOW/YEAR-100YEARS&facet.date.end=NOW/YEAR+1YEAR&facet.date.gap=1YEAR
...but this should cause an error because hte death field doesn't have an
end specified...
facet=true&facet.date=birth&facet.date=death&facet.date.start=NOW/YEAR-100YEARS&f.birth.facet.date.end=NOW/YEAR+1YEAR&facet.date.gap=1YEAR
I'm currently using this...
final SolrParams required = new RequiredSolrParams(params);
...
final String endS = required.getFieldParam(f,SolrParams.FACET_DATE_END);
...but that fails on valid use cases like the first one above, because
getFieldParam delegates to the super which calls
get("f."+f+"."+SolrParams.FACET_DATE_END) .. which triggers this
exception...
org.apache.solr.common.SolrException: Missing required parameter:
f.birth.facet.date.end
at
org.apache.solr.common.params.RequiredSolrParams.get(RequiredSolrParams.java:50)
at
org.apache.solr.common.params.SolrParams.getFieldParam(SolrParams.java:254)
at
org.apache.solr.request.SimpleFacets.getFacetDateCounts(SimpleFacets.java:442)
at
org.apache.solr.request.SimpleFacets.getFacetCounts(SimpleFacets.java:95)
...i considered something like...
final SolrParams required = new RequiredSolrParams(params);
...
final String endS = required.getFieldParam(f,SolrParams.FACET_DATE_END,
params.get(SolrParams.FACET_DATE_END);
..to specify a default value, which would work forthe first use case, but
it wouldn't error in the second use case where neither the generic param
value or the field specific value are specified for a given field.
Looking back at SOLR-183 I see JJ had a comment about this...
> One open question is getFieldParam: Should the semantics of
> required.getFieldParam("facet.limit", "abc") be to fail if the
> parameter is not supplied for the field (e.g. f.abc.facet.limit), or
> not supplied for either the field or as a general default (e.g.
> facet.limit)? In the former case we don't need to override
> getFieldParam. I can't think of a reason that one would want to require
> explicit field values and disallow
> general values, but perhaps someone else could, and a 'field strictness"
> flag should be supplied in the RequiredSolrParams constructor.
to which ryan replied...
>> I don't follow the strict/not strict logic to getFieldParam... If you
>> don't want strict checking, use the normal SolrParams, if you do, use
>> RequiredSolrParams
...it seems like there was maybe a missunderstading there about what JJ
was trying to say, ... either that or i'm really confused.
Is there a way to do what I'm trying to do with RequiredSolrParams right
now that i'm just not realizing, or should we add something to achieve
this?
-Hoss