My client defined two searchComponents in the "components" node of the
suggester request handler. And got two separate sections in the response.
Is this actually supported or just a fortunate happenstance? First time
I've seen it...

Details:
One of my clients discovered this "by accident" (his words). So I wondered
if it was something I'd never learned or whether it's just an unintended
(good) consequence of the code.

The problem is to return suggestions from several fields. One way to do
this is to copyField, but you do lose some information like which
suggestion came from which field. And you bloat the index.

The configuration below returns separate sections for the two
SpellCheckComponents. I removed some stuff for clarity.

Things of interest:
1> the "name" parameter for both seachComponents is the same.
2> the "spellcheck.dictionary" is the same as the "name" component in 1.
3> It works just fine.

<1> and <2> give me some pause as to whether this is robust. It might be
cleaner to add another config param or something...

One problem is that currently the only way to determine which suggestions
came from which field is positional. I.e. the results from "name" come
before "features". This is an artifact of the components being processed in
order and the results being added to the end of the underlying lists. Since
you get an empty list if there are no suggestions in the field, the order
is fine. Of course there's a loose coupling between the order defined in
your config file and the code that's used to read it.

So, it seems to me that this is _that_ close to robustly supporting a
single suggester returning data from separate fields. Or whatever actually,
the searchComponents you put in the request handler could be whatever you
liked. If we added the name of the component to the output, we should be
able to reduce the chance of error if someone goes in and, say, renames the
component in solrconfig.xml. I hacked together a test and it's pretty
straightforward, and I don't _think_ adding a new field breaks back-compat.

I have no clue how this works in distributed mode. But adding the name of
the component seems like it could facilitate distributed suggestions.

So I guess my real question is whether this is formally supported behavior
(first I've seen it) or serendipitous. If the latter, should I raise a JIRA
to give it first-class support?

Erick

<searchComponent class="solr.SpellCheckComponent" name="name">
    <lst name="spellchecker">
      <str name="name">suggest</str>
      <str name="field">name</str>
    </lst>
  </searchComponent>
  <searchComponent class="solr.SpellCheckComponent" name="features">
    <lst name="spellchecker">
      <str name="name">suggest</str>
      <str name="field">features</str>
    </lst>
  </searchComponent>

  <requestHandler class="org.apache.solr.handler.component.SearchHandler"
name="/suggester">
    <lst name="defaults">
      <str name="spellcheck.dictionary">suggest</str>
    </lst>
*    <arr name="components">*
*      <str>name</str>*
*      <str>features</str>*
*    </arr>*
  </requestHandler>

Reply via email to