我正在尝试使用Solarium和PHP从MySQL索引表。为了测试,我有一个国家列表,并在solr中设置了一个核心,以反映我在查询中检索的字段。在尝试添加这些使用Solarium时,我会收到错误:

Fatal error: Uncaught exception 'Solarium_Client_HttpException' with message 'Solr HTTP error: ERROR: [doc=1] unknown field 'code' (400)' in solariumQuickStart\Library\Solarium\Result.php on line 98
( ! ) Solarium_Client_HttpException: Solr HTTP error: ERROR: [doc=1] unknown field 'code' (400) in solariumQuickStart\Library\Solarium\Result.php on line 98
.

在这里是我的代码:

foreach($worldDBRecords as $record)
{

    // create a new document for the data
    $doc = $update->createDocument();
    $doc->code = $record[0];
    $doc->name = $record[1];
    $doc->continent = $record[2];
    $doc->region = $record[3];
    $doc->population = $record[4];
    $update->addDocument($doc);
}

$update->addCommit();
$result = $client->update($update);
.

我与solr的连接工作,我在solarium_client配置中定义了核心。我还有在我的架构文件中定义的代码字段,但无法识别。任何帮助都得到了赞赏。谢谢。

有帮助吗?

解决方案

我重新设置我的solr核心以确保我的配置正确。此外,我缺少我的日光配置中的“aspereptions”设置,它在此之后工作:

$config = array(
'adapteroptions' => array(
'host' => 'localhost',
'port' => 8983,
'path' => '/solr/',
'core' => 'world'
)
);
.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top