12

I have setuped suggester component for autocomplete for one field(it work fine), but I need it for multiple fields is this possible?

My solrconfig xml:

<searchComponent class="solr.SpellCheckComponent" name="suggest">
    <lst name="spellchecker">
      <str name="name">suggest</str>
      <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
      <str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookup</str>
      <str name="field">name</str>
      <float name="threshold">0.005</float>
      <str name="buildOnCommit">true</str>
    </lst>
  </searchComponent>
  <requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/suggest">
    <lst name="defaults">
      <str name="spellcheck">true</str>
      <str name="spellcheck.dictionary">suggest</str>
      <str name="spellcheck.onlyMorePopular">true</str>
      <str name="spellcheck.count">10</str>
      <str name="spellcheck.collate">true</str>
    </lst>
    <arr name="components">
      <str>suggest</str>
    </arr>
  </requestHandler>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
vladimir
  • 695
  • 3
  • 10
  • 23

1 Answers1

10

User copyfields to combine multiple fields into single field and use that field in suggester -

Schema -

<copyField source="name" dest="spell" />
<copyField source="other_name" dest="spell" />

suggester -

<str name="field">spell</str>
Jayendra
  • 52,349
  • 4
  • 80
  • 90
  • Is it need to be added to schema.xml? – Krunal Aug 31 '12 at 12:44
  • It is needed to be added to general_schema_fields.xml – shredding Mar 07 '13 at 14:31
  • @shredding : This is not working for me. by `general_schema_fields.xml`, do you mean `schema.all.xml`. I don't have any file named `general_schema_fields.xml`. Could you have a look at [this](http://stackoverflow.com/questions/20217037/how-to-autocomplete-across-multiple-fields-in-solr) – nish Nov 27 '13 at 10:01
  • On Solr 3.5, I tried to use 2 copyField tags and received an error in Solr about trying to put multiple values into a non-multivalued field. I changed the destination field to multivalue=true and tried again and that didn't work either. – Jeremy Glover May 11 '17 at 22:01