Пример #1
0
 /**
  * Builds the delete query and returns the parsed response
  *
  * @param ezcSearchDeleteQuery $query
  */
 public function delete(ezcSearchDeleteQuery $query)
 {
     $queryWord = join(' AND ', $query->whereClauses);
     $res = $this->search($queryWord);
     foreach ($res as $hit) {
         $this->connection->delete($hit->id);
     }
 }
Пример #2
0
 /**
  * Indexes the document $document using definition $definition
  *
  * @param ezcSearchDocumentDefinition $definition
  * @param mixed $document
  */
 public function index(ezcSearchDocumentDefinition $definition, $document)
 {
     $doc = new Zend_Search_Lucene_Document();
     $doc->addField(Zend_Search_Lucene_Field::Text('ezcsearch_type', $definition->documentType));
     foreach ($definition->fields as $field) {
         $values = $this->mapFieldValuesForIndex($field, $document[$field->field]);
         foreach ($values as $value) {
             switch ($field->type) {
                 case ezcSearchDocumentDefinition::INT:
                 case ezcSearchDocumentDefinition::DATE:
                     $doc->addField(Zend_Search_Lucene_Field::Keyword($field->field, $value));
                     break;
                 default:
                     $doc->addField(Zend_Search_Lucene_Field::Text($field->field, $value));
             }
         }
     }
     $this->connection->addDocument($doc);
 }