Beispiel #1
0
 /**
  * @return APF_Solr_Factory
  */
 public static function &get_instance()
 {
     if (!self::$instance) {
         self::$instance = new MPF_Solr_Factory();
     }
     return self::$instance;
 }
Beispiel #2
0
 public function save($commit = false)
 {
     $doc = new SolrInputDocument();
     foreach ($this->doc_fields as $field => $value) {
         if (!is_array($value)) {
             $doc->addField($field, $value);
         } else {
             foreach ($value as $v) {
                 $doc->addField($field, $v, 1);
             }
         }
     }
     $client = MPF_Solr_Factory::get_instance()->get_client($this->mapping['instance']);
     try {
         $response = $client->addDocument($doc);
     } catch (Exception $e) {
         return false;
     }
     if (!$response instanceof SolrUpdateResponse || $response->getHttpStatus() != 200) {
         //TODO debug info
         return false;
     }
     if ($commit == true) {
         $response = $client->commit();
     }
     return true;
 }