0

我正在尝试使用 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 配置中定义了核心。我还在我的模式文件中定义了代码字段,但它没有被识别。任何帮助表示赞赏。谢谢。

4

1 回答 1

1

我重新设置了 Solr 核心以确保我的配置正确。此外,我在 Solarium 配置中缺少“适配器选项”设置,它在此之后起作用:

$config = array(
'adapteroptions' => array(
'host' => 'localhost',
'port' => 8983,
'path' => '/solr/',
'core' => 'world'
)
);
于 2012-10-10T14:36:48.287 回答