[英]Solr HTTP Error 'Unknown Field' Error using Solarium
I am trying to index a table from MySQL with Solarium and PHP. 我正在尝试使用Solarium和PHP从MySQL索引一个表。 In order to test, I have a list of countries and have set up a core in Solr to reflect the fields I am retrieving in the query.
为了进行测试,我有一个国家列表,并在Solr中设置了一个核心以反映我在查询中检索的字段。 I am getting an error when trying to add these using Solarium:
尝试使用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
and here is my code: 这是我的代码:
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);
My connection to Solr is working and I have defined the core in my Solarium_Client configuration. 我与Solr的连接正在运行,并且已经在Solarium_Client配置中定义了核心。 I also have the code field defined in my schema file, but it is not being recognized.
我在架构文件中也定义了代码字段,但是无法识别。 Any help is appreciated.
任何帮助表示赞赏。 Thanks.
谢谢。
I re-setup my Solr core to make sure my configuration was correct. 我重新设置了Solr核心以确保我的配置正确。 Also, I was missing the 'adapteroptions' setting in my Solarium config, it worked after this:
另外,我在我的Solarium配置中缺少'adapteroptions'设置,在此之后它起作用了:
$config = array(
'adapteroptions' => array(
'host' => 'localhost',
'port' => 8983,
'path' => '/solr/',
'core' => 'world'
)
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.