コード例 #1
0
ファイル: Lucene.class.php プロジェクト: sonicmaster/RPG
 /**
  * Adds a document to the index.
  * 
  * @param	array	documents or fields
  * @param	bool	commit after adding
  * @param	bool	ignore missing fields
  */
 public function add($documents, $commit = true, $ignoreMissingFields = false)
 {
     $this->loadFieldData();
     if (LWUtil::getDimensionCount($documents) == 1) {
         $documents = array($documents);
     }
     foreach ($documents as $fields) {
         $document = new Zend_Search_Lucene_Document();
         foreach ($this->fields as $fieldName => $fieldType) {
             if (!isset($fields[$fieldName])) {
                 if (!$ignoreMissingFields) {
                     var_Dump($fields);
                     require_once WCF_DIR . 'lib/system/exception/SystemException.class.php';
                     throw new SystemException('missing field ' . $fieldName);
                 }
             }
             $field = call_user_func_array(array('Zend_Search_Lucene_Field', $fieldType), array($fieldName, $fields[$fieldName]));
             $document->addField($field);
         }
         $this->getIndex()->addDocument($document);
     }
     if ($commit) {
         $this->getIndex()->commit();
     }
 }