0

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.

Drew
  • 2,601
  • 6
  • 42
  • 65
  • Did you stop and restart Solr after defining the code field in your schema.xml file? The change will not be reflected until Solr is restarted. – Paige Cook Oct 03 '12 at 11:38
  • Thanks for the reply, Paige. I do restart Solr after making any changes. Since Solarium only sends documents to Solr and doesn't actually read the schema file, I believe the problem lies in my configuration of my Solr Core. Still trying to work through this. – Drew Oct 03 '12 at 14:01

1 Answers1

1

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'
)
);
Drew
  • 2,601
  • 6
  • 42
  • 65