Blacklight Plugin

search_fields config can handle Solr parameter LocalParams (de-)referencing

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 2.6
  • Component/s: None
  • Description:
    Hide
    So we have Blacklight config for user-presented search fields (different than Solr fields, the user-presented field may collect a bunch of Solr fields with different boosts, using dismax, etc).

    When we started, each Blacklight search field needed to have it's own request handler in solr.

    This worked, but for some use cases made you repeat a lot of stuff in the solr config, when you had two BL search fields that were pretty much the same but for a small difference, you needed two Solr request handlers that were pretty much copy-and-paste copies but for a small difference.

    Next, what is currently in BL, I added functionality so you could specify any Solr query parameters (qf, pf, mm, etc) with a BL search field, so different search fields could re-use the same same Solr request handler, but apply different qf, pf, etc, however you like. You can of course still have each BL search field have it's own request handler too. That's what's there now.

    So this is more flexibility, but now we've taken some things that you might really want to be specifying in Solr (the particular qf definition for a search field, etc), but they are specified in BL instead. It also adds a lot to your Solr logs, with all of these 'fixed' parameters for a given search field showing up in the Solr logs for those searches.

    So: What I plan to do next, is allow you to use Solr dollar-sign parameter dereferencing in your Blacklight search_field config, and when you have a $value in there, BL will will construct it's solr parameters using Solr LocalParams to reference.

    To show by example, what we've gone through here:

    ORIGINAL: Blacklight.config[:search_fields] << [:author_search, "author"] # qt and label only

    CURRENT:

    Blacklight.config[:search_fields] << { :display_label => "author", :qt => "search",
        :solr_parameters => { :qf => "author_unstem^10 author^5" }
    }

    FUTURE:

    Blacklight.config[:search_fields] << { :display_label => "author", :qt => "search",
        :solr_parameters => { :qf => "$author_qf" }
    }

    => Which would result in BL creating a Solr query with q={! qf=$author_qf} [query]

    The old ways of specifying actual parameters instead of references, or specifying no parameters other than qt, would still be supported too. This is just added flexibility, to allow you to, if you like, share a single Solr request handler between BL "search fields", but still specify the unique qf's etc in Solr, and refer to them with parameter dereferencing.

    This feature may also, I think, be able to be taken advantage of by things like the Advanced Search plugin or my planned CQL plugin, or at least eventually get there. That's my background goal, being able to make things like the Advanced Search plugin cleaner; but I think this change is justified simply for convenience and flexibility of configuration even without that.

    I'm still thinking about the best way to do this, rather than have the code check for a dollar sign in the value, it might make more sense, and be even more flexible, to have a separate key in the search_field, :solr_local_params or something.

    Comments or questions welcome.
    Show
    So we have Blacklight config for user-presented search fields (different than Solr fields, the user-presented field may collect a bunch of Solr fields with different boosts, using dismax, etc). When we started, each Blacklight search field needed to have it's own request handler in solr. This worked, but for some use cases made you repeat a lot of stuff in the solr config, when you had two BL search fields that were pretty much the same but for a small difference, you needed two Solr request handlers that were pretty much copy-and-paste copies but for a small difference. Next, what is currently in BL, I added functionality so you could specify any Solr query parameters (qf, pf, mm, etc) with a BL search field, so different search fields could re-use the same same Solr request handler, but apply different qf, pf, etc, however you like. You can of course still have each BL search field have it's own request handler too. That's what's there now. So this is more flexibility, but now we've taken some things that you might really want to be specifying in Solr (the particular qf definition for a search field, etc), but they are specified in BL instead. It also adds a lot to your Solr logs, with all of these 'fixed' parameters for a given search field showing up in the Solr logs for those searches. So: What I plan to do next, is allow you to use Solr dollar-sign parameter dereferencing in your Blacklight search_field config, and when you have a $value in there, BL will will construct it's solr parameters using Solr LocalParams to reference. To show by example, what we've gone through here: ORIGINAL: Blacklight.config[:search_fields] << [:author_search, "author"] # qt and label only CURRENT: Blacklight.config[:search_fields] << { :display_label => "author", :qt => "search",     :solr_parameters => { :qf => "author_unstem^10 author^5" } } FUTURE: Blacklight.config[:search_fields] << { :display_label => "author", :qt => "search",     :solr_parameters => { :qf => "$author_qf" } } => Which would result in BL creating a Solr query with q={! qf=$author_qf} [query] The old ways of specifying actual parameters instead of references, or specifying no parameters other than qt, would still be supported too. This is just added flexibility, to allow you to, if you like, share a single Solr request handler between BL "search fields", but still specify the unique qf's etc in Solr, and refer to them with parameter dereferencing. This feature may also, I think, be able to be taken advantage of by things like the Advanced Search plugin or my planned CQL plugin, or at least eventually get there. That's my background goal, being able to make things like the Advanced Search plugin cleaner; but I think this change is justified simply for convenience and flexibility of configuration even without that. I'm still thinking about the best way to do this, rather than have the code check for a dollar sign in the value, it might make more sense, and be even more flexible, to have a separate key in the search_field, :solr_local_params or something. Comments or questions welcome.

Activity

Hide
Jonathan Rochkind added a comment - 16/Jun/10 12:19 PM
Okay, I've committed the fix for CODEBASE-231 to let you, use
dollar-sign style LocalParams in your blacklight search_field config.

For instance:

Blacklight.search_fields << { :display_label => "Author",
    :key=>"author",
    :local_solr_parameters => { :qf => "$author_qf" }
}

Which Blacklight will wind up translating to solr query including:
(uri-escaped, but showing non-escaped for clarity)
&q={!qf=$author_qf} actual user query

You'd use that where in your solrconfig for the request handler
involved, you had defined:
<str name="author_qf">
  someField10
  otherField5
</str>

This makes possible more options in your Solr/Blacklight setup.

Even before this patch, you could use just ONE solr request handler, but
specify per-blacklight-field solr params with :solr_parameters -- but
they'd have to be literal solr values, so "someField10 otherField5"
would be defined in Blacklight, and sent with every Solr request.

Now, with :local_solr_parameters, you can use just one solr request
handler, but have the per-search-field configuration in Solr, and have
Blacklight just send the LocalParams variable-dereference-style
"$author_qf".

It seems to me that perhaps I should change the default/example Solr
that comes with Blacklight to use this newly possible style? I think
it's probably more useful/powerful example than what's there now, which
uses a separate Solr request handler per blacklight "search field".
Agree? If so, if someone gives me commit access to the blacklight-solr
sub-project, I'll do that.
Show
Jonathan Rochkind added a comment - 16/Jun/10 12:19 PM Okay, I've committed the fix for CODEBASE-231 to let you, use dollar-sign style LocalParams in your blacklight search_field config. For instance: Blacklight.search_fields << { :display_label => "Author",     :key=>"author",     :local_solr_parameters => { :qf => "$author_qf" } } Which Blacklight will wind up translating to solr query including: (uri-escaped, but showing non-escaped for clarity) &q={!qf=$author_qf} actual user query You'd use that where in your solrconfig for the request handler involved, you had defined: <str name="author_qf">   someField10   otherField5 </str> This makes possible more options in your Solr/Blacklight setup. Even before this patch, you could use just ONE solr request handler, but specify per-blacklight-field solr params with :solr_parameters -- but they'd have to be literal solr values, so "someField10 otherField5" would be defined in Blacklight, and sent with every Solr request. Now, with :local_solr_parameters, you can use just one solr request handler, but have the per-search-field configuration in Solr, and have Blacklight just send the LocalParams variable-dereference-style "$author_qf". It seems to me that perhaps I should change the default/example Solr that comes with Blacklight to use this newly possible style? I think it's probably more useful/powerful example than what's there now, which uses a separate Solr request handler per blacklight "search field". Agree? If so, if someone gives me commit access to the blacklight-solr sub-project, I'll do that.

People

Dates

  • Created:
    26/May/10 12:15 PM
    Updated:
    16/Jun/10 12:19 PM
    Resolved:
    16/Jun/10 12:19 PM