0

I recently tried solr autosuggest search in my local,

Steps I followed :

  1. Added configuration in master in sensoft_master_index\conf\solrconfig.xml enter image description here

  2. Restarted solr8.1 service in services

  3. in C# code,

public IEnumerable GetSuggestion(string term) {

        try
        {
            using (var context = ContentSearchManager.GetIndex("sitecore_master_index").CreateSearchContext())
            {
                SolrSuggestQuery query = term;
                var options = new SuggestHandlerQueryOptions
                {
                    Parameters = new SuggestParameters
                    {
                        Count = 3
                    }
                };

                var result = context.Suggest(query, options);

                return result.Suggestions["default"].Suggestions.Select(a => a.Term);
            }
        }
        catch (Exception e)
        {
            System.IO.File.WriteAllText(@"D:\test1.txt", e.ToString());
        }
        return rr;
    }

But I get the below error

SolrNet.Exceptions.SolrConnectionException:

500 36 java.lang.NullPointerException at org.apache.lucene.search.suggest.fst.FSTCompletionLookup.lookup(FSTCompletionLookup.java:273) at org.apache.lucene.search.suggest.Lookup.lookup(Lookup.java:240) at org.apache.solr.spelling.suggest.SolrSuggester.getSuggestions(SolrSuggester.java:243) at org.apache.solr.handler.component.SuggestComponent.process(SuggestComponent.java:264) at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:298) at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:199) at org.apache.solr.core.SolrCore.execute(SolrCore.java:2566) at org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:756) at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:542) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:397) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:343) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1602) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:540) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1588) at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1557) at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144) at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:220) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) at org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:335) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) at org.eclipse.jetty.server.Server.handle(Server.java:502) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.onFillable(SslConnection.java:411) at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:305) at org.eclipse.jetty.io.ssl.SslConnection$2.succeeded(SslConnection.java:159) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103) at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168) at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126) at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765) at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683) at java.lang.Thread.run(Thread.java:748) 500 ---> System.Net.WebException: The remote server returned an error: (500) Internal Server Error. at System.Net.HttpWebRequest.GetResponse()
at HttpWebAdapters.Adapters.HttpWebRequestAdapter.GetResponse() at SolrNet.Impl.SolrConnection.GetResponse(IHttpWebRequest request) at SolrNet.Impl.SolrConnection.Get(String relativeUrl, IEnumerable1 parameters) --- End of inner exception stack trace --- at SolrNet.Impl.SolrConnection.Get(String relativeUrl, IEnumerable1 parameters) at Sitecore.ContentSearch.SolrNetExtension.Impl.SolrQueryExecuterEx`1.Execute(SolrSuggestQuery query, SuggestHandlerQueryOptions options) at Sitecore.ContentSearch.SolrProvider.SolrNetIntegration.SolrNetProxy.Suggest(IProviderSearchContext context, SolrSuggestQuery q, SuggestHandlerQueryOptions options) at SenSoftPOC.Controllers.HomeController.GetSuggestion(String term) in D:\AmeexProjects\Sensoft\SenSoftPOC\SenSoftPOC\Controllers\HomeController.cs:line 197

3
  • First of all try to remove dictionaryImpl parameter.

  • Second, from my practice, suggester works only with AnalyzingInfixLookupFactory (or without any lookupImpl).

  • Third, check whether your fieldtype that you use for suggester has stored="true" in managed schema.

This is an exmaple of working configuration:

 <searchComponent name="suggest" class="solr.SuggestComponent">
    <lst name="suggester">
      <str name="name">mySuggester</str>
      <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
      <str name="field">pagecontent_t</str>
      <str name="suggestAnalyzerFieldType">text_general</str>
      <str name="buildOnStartup">true</str>
    </lst>
  </searchComponent>

Also you can faced issue that you field is unknown and it can be resolved by adding your field in suggester defaults in solrconfig.xml:

  <initParams path="/suggest">
    <lst name="defaults">
      <str name="df">pagebody_t</str>
    </lst>
  </initParams>
| improve this answer | |
  • <lst name="error"> <lst name="metadata"> <str name="error-class">org.apache.solr.common.SolrException</str> <str name="root-error-class">org.apache.solr.common.SolrException</str> </lst> <str name="msg">No suggester named default was configured</str> <int name="code">400</int> </lst> </response> ---> System.Net.WebException: The remote server returned an error: (400) Bad Request. – Rajasekar Apr 10 at 16:17
  • I tried your suggestions – Rajasekar Apr 10 at 16:17
  • Now working. I have a problem with field type. now working – Rajasekar Apr 11 at 2:08
  • According to your exception, did you add your custom field in initoram in solrconfig.xml? – x3mxray Apr 11 at 10:48
  • I used default field _name. – Rajasekar Apr 12 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.