Hi,

I'm using Solr's Suggester function to implement an autocomplete feature.
I have it setup to check against the "username" and "name" fields.  Problem
is when running  a query against the name, the second term, after
whitespace (surename) returns 0 results.  Works if if query is a partial
name starting from the begining e.g. Given the name "Bill Rogers", a query
for Rogers will return 0 results whereas a query for "Bill" will return
positive (Bill Rogers). As for the username, it's not working at.

I am after the following behaviour.

Match any partial words in the fields "username" or "name" and return the
results.  If there is match in the field "name" the return the whole name
e.g. given the queries "Rogers" or "Bill"" return "Bill Rogers (not the
single word that was a match)".

schema.xml extract
..
<field name="username" type="text_general" indexed="true" stored="true" />
 <field name="name" type="text_general" indexed="true" stored="true"/>
<field name="autocomplete" type="textSpell" indexed="true" stored="false"
multiValued="true" omitNorms="true" omitTermFreqAndPositions="false" />
...
<copyField source="username" dest="autocomplete"/>
<copyField source="name" dest="autocomplete"/>
...

<fieldType class="solr.TextField" name="textSpell"
positionIncrementGap="100">
 <analyzer>
   <tokenizer class="solr.StandardTokenizerFactory"/>
   <filter class="solr.StandardFilterFactory"/>
   <filter class="solr.LowerCaseFilterFactory"/>
 </analyzer>
</fieldType>


solrconfig.xml

....
<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">autocomplete</str>  <!-- the indexed field to derive
suggestions from -->
   <float name="threshold">0.005</float>
   <str name="buildOnCommit">true</str>
   <!--
      <str name="sourceLocation">american-english</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">5</str>
    <str name="spellcheck.collate">true</str>
  </lst>
  <arr name="components">
     <str>spellcheck</str>
  </arr>
</requestHandler>

Reply via email to