使用Solarium php的建议查询中的HTTP错误问题
我正在使用solarium在php codeigiter中实现建议查询。但是在连接到使用Solarium php的建议查询中的HTTP错误问题,php,solr,solarium,Php,Solr,Solarium,我正在使用solarium在php codeigiter中实现建议查询。但是在连接到createSuggester查询时。它显示以下错误行 An uncaught Exception was encountered Type: Solarium\Exception\HttpException Message: Solr HTTP error: OK (404) HTTP ERROR 404 Problem accessing /solr/../suggest. Reason: Not
createSuggester
查询时。它显示以下错误行
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
我的示例代码在这里
$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();
$query=$this->client->createSuggester();
$query->setQuery('ap ip v')//多术语
$query->setDictionary('suggester');
//$query->setonlyrepopular(true);
$query->setCount(10);
//$query->setCollate(true);
//这将执行查询并返回结果
$resultset=$this->client->suggester($query);
回显“Query:”。$Query->getQuery()。
;
//显示每个学期的结果
foreach($resultset作为$term=>$termResult){
回显“.$term.”;
回显'NumFound:'。$termResult->getNumFound()。
;
回显“StartOffset:”。$termResult->getStartOffset()。
;
回显“EndOffset:”。$termResult->getEndOffset()。
;
回应“建议:
”;
foreach($termResult作为$result){
回显'-'.$result'
;
}
回声“
”;
}
//显示排序规则
回显“排序规则:”。$resultset->getCollation();
我试图在许多资源中找到解决方案。但解决方案并不存在。请解释发生此问题的原因。您可以在“solrconfig.xml”中设置默认字典,如下所示:
<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>
不是
'suggester'
在$query->setDictionary('suggester')
,请使用建议者的名称,如$query->setDictionary('mySuggester')
是/solr/。/
实际显示的URL,或者您是否删除了此处的内容?由于它似乎缺少一个核心/集合名称,这就是allUrl issolr/test\u core/suggest.
。在这种情况下,您是否将/suggest
请求处理程序添加为?作为与Solr捆绑的示例核心(techproducts iirc)的一部分,可以随时复制配置。但solarium建议没有结果。有谁能帮我从solarium获得价值
$query->setDictionary('suggester');