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 Jay Luker <lb...@reallywow.com> on 2011/02/16 22:05:02 UTC
Help with parsing configuration using SolrParams/NamedList
Hi,
I'm trying to use a CustomSimilarityFactory and pass in per-field
options from the schema.xml, like so:
<similarity class="org.ads.solr.CustomSimilarityFactory">
<lst name="field_a">
<int name="min">500</int>
<int name="max">10000</int>
<float name="steepness">0.5</float>
</lst>
<lst name="field_b">
<int name="min">500</int>
<int name="max">20000</int>
<float name="steepness">0.5</float>
</lst>
</similarity>
My problem is I am utterly failing to figure out how to parse this
nested option structure within my CustomSimilarityFactory class. I
know that the settings are available as a SolrParams object within the
getSimilarity() method. I'm convinced I need to convert to a NamedList
using params.toNamedList(), but my java fu is too feeble to code the
dang thing. The closest I seem to get is the top level as a NamedList
where the keys are "field_a" and "field_b", but then my values are
strings, e.g., "{min=500,max=10000,steepness=0.5}".
Anyone who could dash off a quick example of how to do this?
Thanks,
--jay
Re: Help with parsing configuration using SolrParams/NamedList
Posted by Markus Jelsma <ma...@openindex.io>.
Hi,
The params you have suggest you're planning to use SweetSpotSimilarity. There
already is a factory you can use in Jira.
https://issues.apache.org/jira/browse/SOLR-1365
Cheers,
> Hi,
>
> I'm trying to use a CustomSimilarityFactory and pass in per-field
> options from the schema.xml, like so:
>
> <similarity class="org.ads.solr.CustomSimilarityFactory">
> <lst name="field_a">
> <int name="min">500</int>
> <int name="max">10000</int>
> <float name="steepness">0.5</float>
> </lst>
> <lst name="field_b">
> <int name="min">500</int>
> <int name="max">20000</int>
> <float name="steepness">0.5</float>
> </lst>
> </similarity>
>
> My problem is I am utterly failing to figure out how to parse this
> nested option structure within my CustomSimilarityFactory class. I
> know that the settings are available as a SolrParams object within the
> getSimilarity() method. I'm convinced I need to convert to a NamedList
> using params.toNamedList(), but my java fu is too feeble to code the
> dang thing. The closest I seem to get is the top level as a NamedList
> where the keys are "field_a" and "field_b", but then my values are
> strings, e.g., "{min=500,max=10000,steepness=0.5}".
>
> Anyone who could dash off a quick example of how to do this?
>
> Thanks,
> --jay