0

I'm implement suggest query in php codeigiter using solarium. But while connect to the createSuggester query. It shows following error line.

An uncaught Exception was encountered
Type: Solarium\Exception\HttpException

Message: Solr HTTP error: OK (404)
HTTP ERROR 404
Problem accessing /solr/../suggest. Reason:

    Not Found
Filename: C:\wamp\www\solariumphp\vendor\solarium\solarium\src\Core\Query\Result\Result.php

Line Number: 59

Backtrace:

File: C:\wamp\www\solariumphp\vendor\solarium\solarium\src\Core\Client\Client.php
Line: 751
Function: __construct

File: C:\wamp\www\solariumphp\vendor\solarium\solarium\src\Core\Client\Client.php
Line: 783
Function: createResult

File: C:\wamp\www\solariumphp\vendor\solarium\solarium\src\Core\Client\Client.php
Line: 978
Function: execute

File: C:\wamp\www\solariumphp\application\controllers\Example.php
Line: 30
Function: suggester

File: C:\wamp\www\solariumphp\index.php
Line: 315
Function: require_once

My sample code is here,

$query = $this->client->createSuggester();
$query->setQuery('ap ip v'); //multiple terms
$query->setDictionary('suggester');
// $query->setOnlyMorePopular(true);
$query->setCount(10);
// $query->setCollate(true);

// this executes the query and returns the result
$resultset = $this->client->suggester($query);

echo '<b>Query:</b> '.$query->getQuery().'<hr/>';

// display results for each term
foreach ($resultset as $term => $termResult) {
    echo '<h3>' . $term . '</h3>';
    echo 'NumFound: '.$termResult->getNumFound().'<br/>';
    echo 'StartOffset: '.$termResult->getStartOffset().'<br/>';
    echo 'EndOffset: '.$termResult->getEndOffset().'<br/>';
    echo 'Suggestions:<br/>';
    foreach ($termResult as $result) {
        echo '- '.$result.'<br/>';
    }

    echo '<hr/>';
}

// display collation
echo 'Collation: '.$resultset->getCollation();

I'm try to find solution in many resources. But the solution is not there. Plese explain me what/why this issue is happened?

  • Is `/solr/../` actually the URL shown, or have you removed something here? As it seems to be missing a core / collection name, that's what's giving you the 404 first of all – MatsLindh Apr 16 '19 at 11:04
  • Url is `solr/test_core/suggest.`. –  Apr 16 '19 at 11:09
  • In that case, have you added the `/suggest` requestHandler as [shown in the reference guide](https://lucene.apache.org/solr/guide/6_6/suggester.html)? There's ready-to-copy configuration available as part of the example cores (techproducts iirc) bundled with Solr. – MatsLindh Apr 16 '19 at 11:24
  • I try this solution. But solarium suggester returning no result. –  Apr 17 '19 at 06:18
  • Any one who help me how to get value from solarium –  Apr 17 '19 at 06:19
  • You'll have to provide more details - if you've tried something and it didn't do what you expected - what was the result? Does the URL work directly in your browser? Does it work in the Solr interface? – MatsLindh Apr 17 '19 at 06:32
  • My output is like there –  Apr 17 '19 at 06:47
  • { "responseHeader":{ "status":0, "QTime":3}, "suggest":{"mySuggester":{ "USS":{ "numFound":0, "suggestions":[]}}}} –  Apr 17 '19 at 06:47
  • I run via brower –  Apr 17 '19 at 06:47
  • But that's a different error than what Solarium is telling you - you'll need to find out what the difference in URLs are - Solarium is saying it's getting a 404 not found, so it's apparently requesting a different URL than what the admin interface is using in the background. Use "developer tools" and the "network" pane in your browser to see where the request ends up (and the query interface in the admin page should show the URL as well) and compare it to what Solarium is complaining about. – MatsLindh Apr 17 '19 at 07:04

2 Answers2

1

you can set the default dictionary in "solrconfig.xml" like this:

<searchComponent name="suggest" class="solr.SuggestComponent">
<lst name="suggester">
    <str name="name">mySuggester</str>
    <str name="lookupImpl">FreeTextLookupFactory</str>
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>
    <str name="field">content</str>
    <str name="suggestFreeTextAnalyzerFieldType">suggestTypeLc</str>
    <str name="buildOnStartup">true</str>
    <str name="buildOnCommit">false</str>
</lst>
</searchComponent>

<requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
    <str name="suggest">true</str>
    <str name="suggest.count">10</str>
    <str name="suggest.dictionary">mySuggester</str>
</lst>
<arr name="components">
    <str>suggest</str>
</arr>
</requestHandler>

and remove this line from your code :

$query->setDictionary('suggester');
0

not 'suggester' at $query->setDictionary('suggester'),please use the name of the suggester like $query->setDictionary('mySuggester')

Jaimil Patel
  • 1,301
  • 6
  • 13
Iurii
  • 1
  • 1