Reputation: 2631
I am trying to index a table from MySQL with Solarium and PHP. 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. I am getting an error when trying to add these using 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. I also have the code field defined in my schema file, but it is not being recognized. Any help is appreciated. Thanks.
Upvotes: 0
Views: 1883
Reputation: 2631
I re-setup my Solr core to make sure my configuration was correct. Also, I was missing the 'adapteroptions' setting in my Solarium config, it worked after this:
$config = array(
'adapteroptions' => array(
'host' => 'localhost',
'port' => 8983,
'path' => '/solr/',
'core' => 'world'
)
);
Upvotes: 1