0

I am trying to use Soalarium suggester with custom handler. This is my php code:

$client = SolrClient::create();
$query = $client->createSuggester();
$query->setHandler("suggest_custom");
$query->setQuery("store");

$rq = $client->createRequest($query);
$debugInfo["requestUri"] = urldecode($rq->getUri());
$resultset = $client->execute($query);

The code executes, but it always returns empty result set. I echoed the request URL and it looks like this:

suggest_custom?omitHeader=true&wt=json&json.nl=flat&suggest=true&suggest.q=store&suggest.build=false&suggest.reload=false

I think the problem is that query is set as suggest.q=store instead of q=store. If I manually open suggest_custom?q.op=OR&q=store&rows=200 link, than it work as expected.

Ideally I would only send suggest_custom?q.op=OR&q=store&rows=200 to Solr server.

Any idea how to use suggester with custom handlers? This is my handler for completion:

  <requestHandler name="/suggest_custom" class="org.apache.solr.handler.component.SearchHandler">
    <lst name="defaults">
      <str name="wt">json</str>
      <str name="defType">edismax</str>
      <str name="rows">5</str>
      <str name="fl">categoryAutocompleteExactMatch</str>
      <str name="qf">categoryAutocompleteExactMatch^10 categoryAutocomplete</str>
    </lst>
  </requestHandler>
sanjihan
  • 5,592
  • 11
  • 54
  • 119
  • You don't need a _suggester_ query instance actually : as long as the `/suggest_custom` request handler has no SuggestComponent nor any specific component defined, it is just a "regular" handler (only the implicit [default search components](https://solr.apache.org/guide/8_11/requesthandlers-and-searchcomponents-in-solrconfig.html#default-components) are invoked). So this means you can use a standard _select_ query instance, ie. `$query = $client->createSelect();`. – EricLavault Jan 29 '23 at 20:31

0 Answers0