I am using solarium to implement a solr search. I need to index my files into solr. I am using the following code to do so.
require('init.php');
use Solarium\Plugin\BufferedAdd\Event\Events;
use Solarium\Plugin\BufferedAdd\Event\PreFlush as PreFlushEvent;
use Solarium\Plugin\BufferedAdd\Event\PostCommit as PostCommitEvent;
/////////////////This function adds the knowledge maps to solr//////////////////////////////
$results_index = query(" select indexed_id from update_solr WHERE table_name='knowledgemaps'");
$results = query(" select m_id,k_id, m_title, m_des from knowledgemaps WHERE k_id>{$results_index[0]['indexed_id']}");
$client = new Solarium\Client($config);
$buffer = $client->getPlugin('bufferedadd');
$buffer->setBufferSize(10);
for($i=0;$i<count($results);$i++) {
// also register an event hook to display what is happening
$client->getEventDispatcher()->addListener(
Events::PRE_FLUSH,
function (PreFlushEvent $event) {
echo 'Flushing buffer (' . count($event->getBuffer()) . 'docs)<br/>';
}
);
// Create a document
$doc = array();
$doc["map_id"]=$results[$i]["m_id"];
$doc["user_id"]=$results[$i]["k_id"];
$doc["map_title"]=$results[$i]["m_title"];
if(isset($results[$i]["m_des"])&&is_null($results[$i]["m_des"])){
$doc["map_des"]=$results[$i]["m_des"];
}
$buffer->createDocument($doc);
}
$buffer->flush();
When I execute the code i do not get any errors. It give the number of flushes documents as correct. But no data is getting indexed in solr.
Is there some additional code required to index the information