<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">I for the moment solved this myself by
      copying CmsSolrIndex.java to my java classes an added the
      following method:<br>
      <small><font face="Courier New, Courier, monospace">    public
          List<String> suggestions(String requestHandler, String
          term, String type) {<br>
                  List<String> resultList = new
          ArrayList<>();<br>
                  try {<br>
                      term = Encoding.encodeISO8859toUTF8(term);<br>
                  } catch (UnsupportedEncodingException e) {<br>
                      LOG.error("could not encode search query to
          UTF-8", e);<br>
                  }<br>
                  ModifiableSolrParams params = new
          ModifiableSolrParams();<br>
                  params.set("qt", requestHandler);<br>
                  params.set("q", term);<br>
                  params.set("spellcheck", "on");<br>
                  params.set("fq", "type:" + type);<br>
                  try {<br>
                      QueryResponse rsp = m_solr.query(params);<br>
                      SpellCheckResponse scresp = 
          rsp.getSpellCheckResponse();<br>
                      if (null != scresp) {<br>
                          List<SpellCheckResponse.Suggestion>
          suggestions = scresp.getSuggestions();<br>
                          if (null != suggestions) {<br>
                              for (SpellCheckResponse.Suggestion sug :
          suggestions) {<br>
                                 
          resultList.addAll(sug.getAlternatives());<br>
                              }<br>
                          }<br>
                      }<br>
                  } catch (Exception e) {<br>
                      LOG.error("Error retrieving suggestions for term 
          " + term, e);<br>
                  }<br>
                  return resultList;<br>
              }</font></small><br>
      <br>
      The passed request handler needs to be defined in solrconfig.xml:<br>
      <small><font face="Courier New, Courier, monospace"> 
          <searchComponent class="solr.SpellCheckComponent"
          name="suggest_de"><br>
              <lst name="spellchecker"><br>
                <str name="name">suggestDictionaryDe</str><br>
                <str
name="classname">org.apache.solr.spelling.suggest.Suggester</str><br>
                <str
name="lookupImpl">org.apache.solr.spelling.suggest.fst.FSTLookupFactory</str><br>
                <str name="field">suggest_de</str><br>
                <float name="threshold">0.</float><br>
                <str name="buildOnCommit">true</str><br>
              </lst><br>
            </searchComponent><br>
            <requestHandler name="/suggest_de"
          class="org.apache.solr.handler.component.SearchHandler"><br>
              <lst name="defaults"><br>
                <str name="echoParams">none</str><br>
                <str name="indent">false</str><br>
                <str name="spellcheck">true</str><br>
                <str
          name="spellcheck.dictionary">suggestDictionaryDe</str><br>
                <str
          name="spellcheck.onlyMorePopular">true</str><br>
                <str name="spellcheck.count">16</str><br>
                <str name="spellcheck.collate">false</str><br>
                </lst><br>
              <arr name="components"><br>
                <str>suggest_de</str><br>
              </arr><br>
            </requestHandler></font></small><br>
      <br>
      and the configured field "<str
      name="field">suggest_de</str>" is mapped in schema.xml:<br>
      <small><font face="Courier New, Courier, monospace"> 
          <copyField source="content_de" dest="suggest_de"/></font></small><br>
      <br>
      Best,<br>
      Tobias<br>
      <br>
      Am 18.06.2014 08:16, schrieb Tobias Karrer:<br>
    </div>
    <blockquote
cite="mid:http:%2F%2Fpermalink.gmane.org%2Fgmane.comp.cms.opencms.devel%2F38918@localhost.localdomain"
      type="cite"><base
        href="http://permalink.gmane.org/gmane.comp.cms.opencms.devel/38918">
      <title>CmsSolrIndex and suggestions</title>
      <base
        href="http://permalink.gmane.org/gmane.comp.cms.opencms.devel/38918">
      <pre>Hi all,

does someone know how to return "suggestions" like it is described in 
<a class="moz-txt-link-freetext" href="http://wiki.apache.org/solr/Suggester">http://wiki.apache.org/solr/Suggester</a> on CmsSolrIndex?

Best,
Tobias
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
<a class="moz-txt-link-freetext" href="http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev">http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev</a>




</pre>
    </blockquote>
    <br>
  </body>
</html>