0
votes

i am trying to use suggeter in my application

example: I have a documents as below

apache solr version 4.2
apache hadoop version 2
cassendra nosql db
mysql rdbms 

if i search for "apa" first two result is shown as suggestion and if the search string is "apache so" only 1st one is shown as suggestion which is as expected

But

if i search for "solr" no result is shown for suggestion( i would expect apache solr version 4.2)

My query is

http://localhost:8983/solr/colletion/suggest?wt=json&indent=true&spellcheck=true&spellcheck.q=solr

below is my field type

 <fieldType name="text_general2" class="solr.TextField" positionIncrementGap="100">
      <analyzer type="index">
        <tokenizer class="solr.KeywordTokenizerFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
	<filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.KeywordTokenizerFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
    </fieldType>

and suggest request handler in solrconfig.xml is

<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.fst.WFSTLookupFactory</str>
     <str name="field">title2</str>  <!-- the indexed field to derive suggestions from -->
      <float name="threshold">0</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">8</str>
      <str name="spellcheck.collate">true</str>
    </lst>
    <arr name="components">
      <str>suggest</str>
    </arr>
  </requestHandler>

my solr version is 4.2 CDH 4.7

please help

1

1 Answers

0
votes

You are using a KeywordTokenizerFactory which treats the entire string as a single stream. So in your case, the 1st document would be indexed as

apache solr version 4.2

Since your auto suggest is turned on, your first query apac & others starting with the same prefix apac can match both the entries in index starting with it (as you have suggest turned on)

If you looking to match individual words in a text you should consider using another Tokenizer such as WhitespaceTokenizerFactory.

More details: https://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.KeywordTokenizerFactory