当前位置: 首页>>代码示例>>PHP>>正文


PHP Apache_Solr_Document::setMultiValue方法代码示例

本文整理汇总了PHP中Apache_Solr_Document::setMultiValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Apache_Solr_Document::setMultiValue方法的具体用法?PHP Apache_Solr_Document::setMultiValue怎么用?PHP Apache_Solr_Document::setMultiValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Apache_Solr_Document的用法示例。


在下文中一共展示了Apache_Solr_Document::setMultiValue方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: indexItem

 /**
  * This indexes something that implements Mixin_ElementText into a Solr Document.
  *
  * @param array                $fields The fields to index.
  * @param Mixin_ElementText    $item   The item containing the element texts.
  * @param Apache_Solr_Document $doc    The document to index everything into.
  * @return void
  * @author Eric Rochester <erochest@virginia.edu>
  **/
 public static function indexItem($fields, $item, $doc)
 {
     foreach ($item->getAllElementTexts() as $text) {
         $field = $fields->findByText($text);
         // Set text field.
         if ($field->is_indexed) {
             $doc->setMultiValue($field->indexKey(), $text->text);
         }
         // Set string field.
         if ($field->is_facet) {
             $doc->setMultiValue($field->facetKey(), $text->text);
         }
     }
 }
开发者ID:AdrienneSerra,项目名称:Digitalsc,代码行数:23,代码来源:SolrSearch_Helpers_Index.php

示例2: pushDocuments

 /**
  * 
  * @param Apache_Solr_Document or Array $parts
  * 
  * @return SP_Controller_Action_Helper_Solr
  */
 public function pushDocuments($parts)
 {
     $this->_setSolrService();
     if ($parts instanceof Apache_Solr_Document) {
         $this->documents[] = $parts;
     } else {
         if (is_array($parts)) {
             foreach ($parts as $item => $fields) {
                 if ($fields instanceof Apache_Solr_Document) {
                     $this->documents[] = $fields;
                 } else {
                     $part = new Apache_Solr_Document();
                     foreach ($fields as $key => $value) {
                         if (is_array($value)) {
                             foreach ($value as $datum) {
                                 $part->setMultiValue($key, $datum);
                             }
                         } else {
                             $part->setField($key, $value);
                         }
                     }
                     $this->documents[] = $part;
                 }
             }
         } else {
             trigger_error("the paramter \$part must be an object of Apache_Solr_Document or an array");
         }
     }
     return $this;
 }
开发者ID:victorli,项目名称:ShrimpProject,代码行数:36,代码来源:Solr.php

示例3: addDocument

 public function addDocument($data)
 {
     $document = new Apache_Solr_Document();
     foreach ($data as $key => $value) {
         if (is_array($value)) {
             foreach ($value as $datum) {
                 if (is_numeric($datum)) {
                     number_format($datum);
                 }
                 $document->setMultiValue($key, $datum);
             }
         } else {
             if (is_numeric($value)) {
                 number_format($value);
             }
             $document->{$key} = $value;
         }
     }
     try {
         $rs = $this->_solrService->addDocument($document);
         // asynchronous commit
         // $this->_solrService->commit(true);
         return $rs;
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }
开发者ID:ubriela,项目名称:solr-websearch,代码行数:27,代码来源:Services.php

示例4: addDocuments

 public function addDocuments($datas)
 {
     $documents = array();
     foreach ($datas as $item => $fields) {
         $part = new Apache_Solr_Document();
         foreach ($fields as $key => $value) {
             if (is_array($value)) {
                 foreach ($value as $datum) {
                     $part->setMultiValue($key, $datum);
                 }
             } else {
                 $part->{$key} = $value;
             }
         }
         $documents[] = $part;
     }
     try {
         $rs = $this->_solrService->addDocuments($documents);
         // asynchronous commit
         //$this->_solrService->commit(true);
         return $rs;
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }
开发者ID:ubriela,项目名称:solr-websearch,代码行数:25,代码来源:Services.php

示例5: testSetMultiValueCreatesMultiValueWhenFieldDoesExistAsSingleValue

 /**
  *	setMultiValue has been deprecated and defers to addField
  *
  *	@deprecated
  */
 public function testSetMultiValueCreatesMultiValueWhenFieldDoesExistAsSingleValue()
 {
     $field = 'field';
     $value1 = 'value1';
     $value2 = 'value2';
     // set first value as singular value
     $this->_fixture->{$field} = $value1;
     // add a second value with addField
     $this->_fixture->setMultiValue($field, $value2);
     // check that value is an array with correct values
     $fieldValue = $this->_fixture->{$field};
     $this->assertTrue(is_array($fieldValue));
     $this->assertEquals(2, count($fieldValue));
     $this->assertEquals($value1, $fieldValue[0]);
     $this->assertEquals($value2, $fieldValue[1]);
 }
开发者ID:rande,项目名称:sfSolrPlugin,代码行数:21,代码来源:DocumentTest.php

示例6: cromSolar

 public function cromSolar($id, $caso = null)
 {
     $adapter = $this->tableGateway->getAdapter();
     $sql = new Sql($adapter);
     $selecttot = $sql->select()->from('ta_plato')->join(array('c' => 'ta_comentario'), 'c.ta_plato_in_id=ta_plato.in_id', array('cantidad' => new \Zend\Db\Sql\Expression('COUNT(c.in_id)')), 'left')->join('ta_tipo_plato', 'ta_plato.ta_tipo_plato_in_id=ta_tipo_plato.in_id ', array('tipo_plato_nombre' => 'va_nombre'), 'left')->join(array('pl' => 'ta_plato_has_ta_local'), 'pl.Ta_plato_in_id = ta_plato.in_id', array(), 'left')->join(array('tl' => 'ta_local'), 'tl.in_id = pl.Ta_local_in_id', array('latitud' => 'de_latitud', 'longitud' => 'de_longitud', 'direccion' => 'va_direccion', 'telefono' => 'va_telefono'), 'left')->join(array('tr' => 'ta_restaurante'), 'tr.in_id = tl.ta_restaurante_in_id', array('restaurant_nombre' => 'va_nombre', 'restaurant_estado' => 'en_estado'), 'left')->join(array('tc' => 'ta_tipo_comida'), 'tc.in_id = tr.Ta_tipo_comida_in_id', array('nombre_tipo_comida' => 'va_nombre_tipo'), 'left')->join(array('tu' => 'ta_ubigeo'), 'tu.in_id = tl.ta_ubigeo_in_id', array('distrito' => 'ch_distrito', 'departamento' => 'ch_departamento'), 'left')->where(array('ta_plato.in_id' => $id));
     $selecttot->group('ta_plato.in_id');
     $selectString = $sql->getSqlStringForSqlObject($selecttot);
     $results = $adapter->query($selectString, $adapter::QUERY_MODE_EXECUTE);
     $plato = $results->toArray();
     $selectto = $sql->select()->from('ta_plato')->join(array('tpt' => 'ta_plato_has_ta_tag'), 'tpt.Ta_plato_in_id = ta_plato.in_id', array('tag_id' => 'ta_tag_in_id'), 'left')->join(array('tt' => 'ta_tag'), 'tt.in_id =tpt.ta_tag_in_id', array('tag' => 'va_nombre'), 'left')->where(array('ta_plato.in_id' => $id));
     $selectStrin = $sql->getSqlStringForSqlObject($selectto);
     $result = $adapter->query($selectStrin, $adapter::QUERY_MODE_EXECUTE);
     $tag = $result->toArray();
     $solr = \Classes\Solr::getInstance()->getSolr();
     if ($solr->ping()) {
         if ($caso !== 1) {
             $solr->deleteByQuery('id:' . $id);
         }
         $document = new \Apache_Solr_Document();
         $document->id = $id;
         $document->name = $plato[0]['va_nombre'];
         $document->tx_descripcion = $plato[0]['tx_descripcion'];
         $document->va_precio = $plato[0]['va_precio'];
         $document->en_estado = $plato[0]['en_estado'];
         $document->plato_tipo = $plato[0]['tipo_plato_nombre'];
         $document->va_direccion = $plato[0]['direccion'];
         $document->restaurante = $plato[0]['restaurant_nombre'];
         $document->tipo_comida = $plato[0]['nombre_tipo_comida'];
         $document->en_destaque = $plato[0]['en_destaque'];
         $document->va_telefono = $plato[0]['telefono'];
         $document->latitud = $plato[0]['latitud'];
         $document->longitud = $plato[0]['longitud'];
         $document->departamento = $plato[0]['departamento'];
         foreach ($tag as $resultado) {
             $document->setMultiValue('tag', $resultado['tag']);
         }
         $document->distrito = $plato[0]['distrito'];
         $document->va_imagen = $plato[0]['va_imagen'];
         $document->comentarios = $plato[0]['cantidad'];
         $document->restaurant_estado = $plato[0]['restaurant_estado'];
         $document->puntuacion = $plato[0]['Ta_puntaje_in_id'];
         $solr->addDocument($document);
         $solr->commit();
     }
 }
开发者ID:kevcast,项目名称:lsrefactoring,代码行数:45,代码来源:ComentariosTable.php

示例7: db_store_article


//.........这里部分代码省略.........
        $num_authors = count($article->authors);
        $count = 0;
        if ($num_authors > 0) {
            foreach ($article->authors as $author) {
                $text .= $author->forename . ' ' . $author->lastname;
                if (isset($author->suffix)) {
                    $text .= ' ' . $author->suffix;
                }
                $count++;
                if ($count == 2 && $num_authors > 3) {
                    $text .= ' et al.';
                    break;
                }
                if ($count < $num_authors - 1) {
                    $text .= ', ';
                } else {
                    if ($count < $num_authors) {
                        $text .= ' and ';
                    }
                }
            }
        }
        $item['citation'] = $text . ' ' . $citation;
        $parts = array();
        $parts[] = $item;
        //print_r($parts);
        // add to solr
        $documents = array();
        foreach ($parts as $item => $fields) {
            $part = new Apache_Solr_Document();
            foreach ($fields as $key => $value) {
                if (is_array($value)) {
                    foreach ($value as $datum) {
                        $part->setMultiValue($key, $datum);
                    }
                } else {
                    $part->{$key} = $value;
                }
            }
            $documents[] = $part;
        }
        //
        //
        // Load the documents into the index
        //
        try {
            $solr->addDocuments($documents);
            $solr->commit();
            $solr->optimize();
        } catch (Exception $e) {
            echo $e->getMessage();
        }
    } else {
        $sql = 'DELETE FROM rdmp_text_index WHERE (object_uri=' . $db->qstr($config['web_root'] . 'reference/' . $id) . ')';
        $result = $db->Execute($sql);
        if ($result == false) {
            die("failed [" . __FILE__ . ":" . __LINE__ . "]: " . $sql);
        }
        // Only do this if we have a title, as sometimes we don't (e.g. CrossRef lacks metadata)
        if (isset($article->title)) {
            $sql = 'INSERT INTO rdmp_text_index(object_type, object_id, object_uri, object_text)
			VALUES ("title"' . ', ' . $id . ', ' . $db->qstr($config['web_root'] . 'reference/' . $id) . ', ' . $db->qstr($article->title) . ')';
            $result = $db->Execute($sql);
            if ($result == false) {
                die("failed [" . __FILE__ . ":" . __LINE__ . "]: " . $sql);
            }
开发者ID:rdmpage,项目名称:bioguid,代码行数:67,代码来源:db.php

示例8: dirname

<?php

require dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new limeade_test(2, limeade_output::get());
$t->diag('document format a document');
$document = new Apache_Solr_Document();
$document->setBoost(10);
$document->setField('sfl_guid', 'GUID_1234');
$document->setField('name', 'Thomas Rabaix', 1);
$document->setMultiValue('skills', 'php');
$document->setMultiValue('skills', 'symfony');
$document->addField('skills', 'objective-c');
$expected = array('name' => 'skills', 'value' => array(0 => 'php', 1 => 'symfony', 2 => 'objective-c'), 'boost' => false);
$t->cmp_ok($document->getField('skills'), '==', $expected, '::getField test multivalue setter');
$expected = array('name' => 'name', 'value' => 'Thomas Rabaix', 'boost' => 1);
$t->cmp_ok($document->getField('name'), '==', $expected, '::getField test setter');
开发者ID:rande,项目名称:sfSolrPlugin,代码行数:16,代码来源:apache_solr_document.php

示例9: array

     			$item['citation'] = reference_authors_to_text_string($reference)
     				. ' ' . $reference->year 
     				. ' ' . $reference->title
     				. ' ' . reference_to_citation_text_string($reference);
     */
     print_r($item);
     $parts[] = $item;
 }
 print_r($parts);
 $documents = array();
 foreach ($parts as $item => $fields) {
     $part = new Apache_Solr_Document();
     foreach ($fields as $key => $value) {
         if (is_array($value)) {
             foreach ($value as $datum) {
                 $part->setMultiValue($key, $datum);
             }
         } else {
             $part->{$key} = $value;
         }
     }
     $documents[] = $part;
 }
 //
 //
 // Load the documents into the index
 //
 try {
     $solr->addDocuments($documents);
     $solr->commit();
     $solr->optimize();
开发者ID:rdmpage,项目名称:bioguid,代码行数:31,代码来源:solr_bulk_load.php

示例10: indexItem

 /**
  * This indexes something that implements Mixin_ElementText into a Solr Document.
  *
  * @param array                $fields The fields to index.
  * @param Mixin_ElementText    $item   The item containing the element texts.
  * @param Apache_Solr_Document $doc    The document to index everything into.
  * @return void
  * @author Eric Rochester <erochest@virginia.edu>
  **/
 public static function indexItem($fields, $item, $doc)
 {
     foreach ($item->getAllElementTexts() as $text) {
         $field = $fields->findByText($text);
         // MAKE SURE EVERYTHING IS INDEXED! AND THAT ALL DATA IS FACETED, BUT NOT SHOWN AS A FACET
         if ($field->element_id == '39') {
             if (self::get_elements_private_status_by_value($text->text, "Title", 4)) {
                 //                    _log("ANONIMOUS VERTELLER: " . $text->text);
                 $doc->setMultiValue($field->indexKey(), "anoniem");
                 //anonymous for public
                 $doc->setMultiValue($field->facetKey(), "anoniem");
                 $doc->setMultiValue($field->indexKey() . "_admin", $text->text);
                 $doc->setMultiValue($field->facetKey() . "_admin", $text->text);
             } else {
                 $doc->setMultiValue($field->indexKey(), $text->text);
                 $doc->setMultiValue($field->facetKey(), $text->text);
                 $doc->setMultiValue($field->indexKey() . "_admin", $text->text);
                 $doc->setMultiValue($field->facetKey() . "_admin", $text->text);
             }
         } elseif ($field->element_id == '60') {
             if (self::get_elements_private_status_by_value($text->text, "Title", 9) || self::get_elements_private_status_by_value($text->text, "Title", 4)) {
                 //                    _log("ANONIMOUS VERZAMELAAR: " . $text->text);
                 $doc->setMultiValue($field->indexKey(), "anoniem");
                 //anonymous for public
                 $doc->setMultiValue($field->facetKey(), "anoniem");
                 $doc->setMultiValue($field->indexKey() . "_admin", $text->text);
                 $doc->setMultiValue($field->facetKey() . "_admin", $text->text);
             } else {
                 $doc->setMultiValue($field->indexKey(), $text->text);
                 $doc->setMultiValue($field->facetKey(), $text->text);
                 $doc->setMultiValue($field->indexKey() . "_admin", $text->text);
                 $doc->setMultiValue($field->facetKey() . "_admin", $text->text);
             }
         } else {
             //if there are no special privacy problems:
             // Set text field.
             if ($field->is_indexed) {
                 $doc->setMultiValue($field->indexKey(), $text->text);
             }
             // Set string field.
             // ADJUST: MAKE AN EXTRA SETTING FOR SHOWING FACETS IN SEQUENCE ->SET ALL TO IS_FACET
             if ($field->is_facet) {
                 $doc->setMultiValue($field->facetKey(), $text->text);
             }
         }
     }
 }
开发者ID:CATCH-FACT,项目名称:SolrSearch-VB,代码行数:56,代码来源:SolrSearch_Helpers_Index.php

示例11: prepareBookFull

 /**
  * Полностью подготавливаем документ книги для solr, с жанрами, авторами и всем прочим.
  * Ресурсоемко, использовать только демоном
  * @param Book $book
  */
 public function prepareBookFull(Book $book)
 {
     $fields = array("id" => '', "id_main_file" => '', "quality" => '', "year" => '', "mark" => '', "rating" => '', "book_type" => '', "download_count" => '', "title" => '', "subtitle" => '', "keywords" => '', "is_cover" => 'bool', "is_duplicate" => 'bool', "is_deleted" => 'bool', "is_blocked" => 'bool', "is_public" => 'bool');
     if (!$book->loaded) {
         return false;
     }
     $document = new Apache_Solr_Document();
     foreach ($fields as $name => $type) {
         if (isset($book->data[$name])) {
             if ($type == 'bool') {
                 $document->{$name} = $book->data[$name] > 0 ? 1 : 0;
             } else {
                 $document->{$name} = $book->data[$name];
             }
         }
     }
     // правообладатели - списочком
     if ($this->rightHolders === null) {
         $this->loadRightHolders();
     }
     $document->rightholder = $this->rightHolders[$book->data['id_rightholder']]['title'];
     // авторы
     $authors = $book->getAuthors();
     foreach ($authors as $author) {
         $document->setMultiValue("author", $author['first_name'] . ' ' . $author['last_name'] . ' ' . $author['middle_name'] . ' ');
     }
     // жанры
     $genres = $book->getGenres();
     foreach ($genres as $genre) {
         $document->setMultiValue("genre", $genre['title']);
     }
     // серии
     $series = $book->getSeries();
     foreach ($series as $serie) {
         $document->setMultiValue("serie", $serie['title']);
     }
     return $document;
 }
开发者ID:rasstroen,项目名称:metro,代码行数:43,代码来源:Search.php

示例12: elseif

     } elseif ($col == 'approvedByCounselDate') {
         $recordsArray[$col] = $value;
     } elseif ($col == 'recordCode') {
         $recordsArray[$col] = $value;
     }
 }
 // place record set into 'records' array
 $solrData['records'] = $recordsArray;
 // build solr XML using recordsArray values
 $documents = array();
 foreach ($solrData as $item => $fields) {
     $record = new Apache_Solr_Document();
     foreach ($fields as $key => $value) {
         if (is_array($value)) {
             foreach ($value as $datum) {
                 $record->setMultiValue($key, $datum);
             }
         } else {
             $record->{$key} = $value;
         }
     }
     $documents[] = $record;
 }
 //
 //
 // Load the documents into the solr index
 //
 try {
     $solr->addDocuments($documents);
     $solr->commit();
     $solr->optimize();
开发者ID:JhunCabas,项目名称:records-authority,代码行数:31,代码来源:solrIndexer.php

示例13: solrStore

  public function solrStore($contact) {

    $doc = new Apache_Solr_Document();

    $doc->setField('id', $contact->id);
    $doc->setField('timecreate', $contact->timecreate->format('Y-m-d\TH:i:s\Z'));
    $doc->setField('timeupdate', $contact->timeupdate->format('Y-m-d\TH:i:s\Z'));
    $doc->setField('usercreate', $contact->usercreate);
    $doc->setField('userupdate', $contact->userupdate);
    $doc->setField('datasource', $contact->datasource_id);
    $doc->setField('domain', $GLOBALS['obm']['domain_id']);
    $doc->setField('in', $contact->addressbook);
    $doc->setField('addressbookId', $contact->addressbook_id);
    $doc->setField('company', $contact->company);
    $doc->setField('companyId', $contact->company_id);
    $doc->setField('commonname', $contact->commonname);
    $doc->setField('lastname', $contact->lastname);
    $doc->setField('firstname', $contact->firstname);
    $doc->setField('middlename', $contact->mname);
    $doc->setField('sortable', $contact->lastname." ".$contact->firstname);
    $doc->setField('suffix', $contact->suffix);
    $doc->setField('aka', $contact->aka);
    $doc->setField('kind', $contact->kind);
    //$doc->setField('kind', $db->f('kind_header'));
    $doc->setField('manager', $contact->manager);
    $doc->setField('assistant', $contact->assistant);
    $doc->setField('spouse', $contact->spouse);
    $doc->setField('birthdayId', $contact->birthday_event);
    $doc->setField('anniversaryId', $contact->anniversary_event);
    if($contact->birthday) $doc->setField('birthday', $contact->birthday->format('Y-m-d\TH:i:s\Z'));
    if($contact->anniversary) $doc->setField('anniversary', $contact->anniversary->format('Y-m-d\TH:i:s\Z'));
    $doc->setField('category', $contact->category);
    foreach($contact->categories as $category) {
      foreach($category as $c) {
        $doc->setMultiValue('categoryId', $c['id']);
      }
    }
    $doc->setField('service', $contact->service);
    $doc->setField('function', $contact->function);
    $doc->setField('title', $contact->title);
    if ($contact->archive) {
      $doc->setField('is', 'archive');
    }
    if ($contact->collected) {
      $doc->setField('is', 'collected');
    }
    if ($contact->mailok) {
      $doc->setField('is', 'mailing');
    }        
    if ($contact->newsletter) {
      $doc->setField('is', 'newsletter');
    }
    if($contact->date) $doc->setField('date', $contact->date->format('Y-m-d\TH:i:s\Z'));
    $doc->setField('comment', $contact->comment);
    $doc->setField('comment2', $contact->comment2);
    $doc->setField('comment3', $contact->comment3);
    $doc->setField('from', $contact->origin);

    foreach($contact->email as $email) {
      $doc->setMultiValue('email', $email['address']);
    }

    foreach($contact->phone as $phone) {
      $doc->setMultiValue('phone', $phone['number']);
    }

    foreach($contact->im as $im) {
      $doc->setMultiValue('jabber', $im['address']);
    }

    foreach($contact->address as $address) {
      $doc->setMultiValue('street', $address['street']);
      $doc->setMultiValue('zipcode', $address['zipcode']);
      $doc->setMultiValue('expresspostal', $address['expresspostal']);
      $doc->setMultiValue('town', $address['town']);
      $doc->setMultiValue('country', $address['country']);
    }

    if($contact->hasACalendarUrl()){
      $doc->setField('hasACalendar', "true");
    }
    else {
      $doc->setField('hasACalendar', "false");
    }

    OBM_IndexingService::store('contact', array($doc));
  }
开发者ID:Kervinou,项目名称:OBM,代码行数:87,代码来源:of_contact.php


注:本文中的Apache_Solr_Document::setMultiValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。