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


PHP SphinxClient::UpdateAttributes方法代码示例

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


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

示例1: removeRecord

 /**
  * {@inheritdoc}
  */
 public function removeRecord(\record_adapter $record)
 {
     if (!$this->rt_conn) {
         throw new RuntimeException('Unable to connect to sphinx real-time index');
     }
     $CRCdatabox = $this->CRCdatabox($record->get_databox());
     $indexes = ["metadatas" . $CRCdatabox, "metadatas" . $CRCdatabox . "_stemmed_en", "metadatas" . $CRCdatabox . "_stemmed_fr", "metadatas" . $CRCdatabox . "_stemmed_de", "metadatas" . $CRCdatabox . "_stemmed_nl"];
     $RTindexes = ["metas_realtime" . $CRCdatabox, "metas_realtime_stemmed_fr_" . $CRCdatabox, "metas_realtime_stemmed_en_" . $CRCdatabox, "metas_realtime_stemmed_nl_" . $CRCdatabox, "metas_realtime_stemmed_de_" . $CRCdatabox];
     foreach ($record->get_caption()->get_fields(null, true) as $field) {
         foreach ($field->get_values() as $value) {
             foreach ($indexes as $index) {
                 $this->sphinx->UpdateAttributes($index, ["deleted"], [$value->getId() => [1]]);
             }
             foreach ($RTindexes as $index) {
                 $this->rt_conn->exec("DELETE FROM " . $index . " WHERE id = " . $value->getId());
             }
         }
     }
     $indexes = ["documents" . $CRCdatabox, "documents" . $CRCdatabox . "_stemmed_fr", "documents" . $CRCdatabox . "_stemmed_en", "documents" . $CRCdatabox . "_stemmed_de", "documents" . $CRCdatabox . "_stemmed_nl"];
     $RTindexes = ["docs_realtime" . $CRCdatabox, "docs_realtime_stemmed_fr_" . $CRCdatabox, "docs_realtime_stemmed_en_" . $CRCdatabox, "docs_realtime_stemmed_nl_" . $CRCdatabox, "docs_realtime_stemmed_de_" . $CRCdatabox];
     foreach ($indexes as $index) {
         $this->sphinx->UpdateAttributes($index, ["deleted"], [$record->get_record_id() => [1]]);
     }
     foreach ($RTindexes as $index) {
         $this->rt_conn->exec("DELETE FROM " . $index . " WHERE id = " . $record->get_record_id());
     }
     return $this;
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:31,代码来源:SphinxSearchEngine.php

示例2: index_remove

 /**
  * Delete a post from the index after it was deleted
  */
 public function index_remove($post_ids, $author_ids, $forum_ids)
 {
     $values = array();
     foreach ($post_ids as $post_id) {
         $values[$post_id] = array(1);
     }
     $this->sphinx->UpdateAttributes($this->indexes, array('deleted'), $values);
 }
开发者ID:Voxel37,项目名称:phpbb,代码行数:11,代码来源:fulltext_sphinx.php

示例3: fopen

fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
fclose($file);
$client->SetWeights(array());
// anchor
$client->SetGeoAnchor("latitude", "longitude", 10.0, 95.0);
$file = fopen("spec/fixtures/data/anchor.bin", "w");
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
fclose($file);
$client->ResetFilters();
// rank_mode
$client->SetRankingMode(SPH_RANK_WORDCOUNT);
$file = fopen("spec/fixtures/data/rank_mode.bin", "w");
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
fclose($file);
$client->SetRankingMode(SPH_RANK_PROXIMITY_BM25);
// index_weights
$client->SetIndexWeights(array("people" => 101));
$file = fopen("spec/fixtures/data/index_weights.bin", "w");
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
fclose($file);
$client->SetIndexWeights(array());
// index_weights
$client->SetFieldWeights(array("city" => 101));
$file = fopen("spec/fixtures/data/field_weights.bin", "w");
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
fclose($file);
$client->SetFieldWeights(array());
// update_simple
$file = fopen("spec/fixtures/data/update_simple.bin", "w");
fwrite($file, $client->UpdateAttributes("people", array("birthday"), array(1 => array(191163600))));
fclose($file);
开发者ID:rafasashi,项目名称:gitorious,代码行数:31,代码来源:data_generator.php

示例4: update

 public function update($index, array $attrs, array $values, $mfa = false)
 {
     return $this->sphinxClient->UpdateAttributes($index, $attrs, $values, $mfa);
 }
开发者ID:jerrylsxu,项目名称:yii-sphinx,代码行数:4,代码来源:ESphinxConnection.php

示例5: SphinxClient

<?php

require "spec/fixtures/sphinxapi.php";
$cl = new SphinxClient();
$cl->UpdateAttributes('index', array('group', 'category'), array(123 => array(array(456, 789), array(1, 2, 3))), true);
开发者ID:alpbs,项目名称:sphinx,代码行数:5,代码来源:update_attributes_mva.php

示例6: SphinxClient

<?php

require "spec/fixtures/sphinxapi.php";
$cl = new SphinxClient();
$cl->UpdateAttributes('index', array('group'), array(123 => array(456)));
开发者ID:alpbs,项目名称:sphinx,代码行数:5,代码来源:update_attributes.php

示例7: get_item_status


//.........这里部分代码省略.........
         if ($current_json) {
             $cached = TRUE;
         }
     } else {
         if (!$force_refresh && $this->locum_config['avail_cache']['cache']) {
             // check the cache table
             $cutoff_timestamp = time() - 60 * $this->locum_config['avail_cache']['cache_cutoff'];
             if ($this->redis->zscore('availcache:timestamps', $bnum) > $cutoff_timestamp) {
                 $cached = TRUE;
             }
         }
     }
     if ($cached) {
         $result = json_decode($current_json, TRUE);
         // return as array
     } else {
         // Scrape and store new availability data
         if ($bib = self::get_bib_item($bnum)) {
             $skiporder = $bib['mat_code'] == 's';
             $status = $this->locum_cntl->item_status($bnum, $skiporder);
             $result['avail'] = 0;
             $result['total'] = count($status['items']);
             $result['libuse'] = 0;
             $result['holds'] = $status['holds'];
             $result['on_order'] = $status['on_order'];
             $result['orders'] = count($status['orders']) ? $status['orders'] : array();
             $result['nextdue'] = 0;
             $result['locations'] = array();
             $result['callnums'] = array();
             $result['ages'] = array();
             $result['branches'] = array();
             $loc_codes = array();
             if (count($status['items'])) {
                 foreach ($status['items'] as &$item) {
                     // Tally availability
                     $result['avail'] += $item['avail'];
                     // Tally libuse
                     $result['libuse'] += $item['libuse'];
                     // Parse Locations
                     $result['locations'][$item['loc_code']][$item['age']]['avail'] += $item['avail'];
                     $result['locations'][$item['loc_code']][$item['age']]['total']++;
                     // Parse Ages
                     $result['ages'][$item['age']]['avail'] += $item['avail'];
                     $result['ages'][$item['age']]['total']++;
                     // Parse Branches
                     $result['branches'][$item['branch']]['avail'] += $item['avail'];
                     $result['branches'][$item['branch']]['total']++;
                     // Parse Callnums
                     //            if ($item['callnum'] !== $bib['callnum'] && strstr($bib['callnum'], $item['callnum'])) {
                     //              $item['callnum'] = $bib['callnum'];
                     //            }
                     $result['callnums'][$item['callnum']]['avail'] += $item['avail'];
                     $result['callnums'][$item['callnum']]['total']++;
                     // Determine next item due date
                     if ($result['nextdue'] == 0 || $item['due'] > 0 && $result['nextdue'] > $item['due']) {
                         $result['nextdue'] = $item['due'];
                     }
                     // Parse location code
                     if (!in_array($item['loc_code'], $loc_codes) && trim($item['loc_code'])) {
                         $loc_codes[] = $item['loc_code'];
                     }
                 }
             }
             $result['items'] = $status['items'];
             // Cache the result
             $this->redis->zadd('availcache:timestamps', time(), $bnum);
             $available_json = json_encode($result);
             if ($available_json != $current_json) {
                 // Only update the cache if the scraped value is different than the current value
                 $this->redis->set('availcache:' . $bnum, $available_json);
                 // Update Location Attributes in Sphinx
                 $branches = array();
                 foreach ($result['branches'] as $branch => $details) {
                     if ($details['avail']) {
                         $branches[] = crc32($branch);
                         // UpdateAttributes automatically converts to unsigned
                     }
                 }
                 if (count($branches)) {
                     $branches[] = crc32('any');
                     // UpdateAttributes automatically converts to unsigned
                 }
                 require_once $this->locum_config['sphinx_config']['api_path'] . '/sphinxapi.php';
                 $cl = new SphinxClient();
                 $cl->SetServer($this->locum_config['sphinx_config']['server_addr'], (int) $this->locum_config['sphinx_config']['server_port']);
                 // Specify indexes to update (abstract into config?)
                 $indexes = 'bib_items_keyword ' . 'bib_items_author ' . 'bib_items_title ' . 'bib_items_subject ' . 'bib_items_callnum ' . 'bib_items_tags ' . 'bib_items_reviews';
                 $index_count = 7;
                 // Match count of index names in $indexes string
                 $update_num = $cl->UpdateAttributes($indexes, array('branches'), array($bnum => array($branches)), TRUE);
                 if ($update_num != $index_count) {
                     $log = '[' . date("Y-m-d H:i:s") . '] record num: b' . $bnum . ', updated ' . $update_num . '/' . $index_count . ' indices';
                     $this->redis->set('availcache:mva_update:last_error', $log);
                     $this->redis->incr('availcache:mva_update:error_count');
                 }
             }
         }
     }
     return $result;
 }
开发者ID:aadl,项目名称:locum,代码行数:101,代码来源:locum-client.php

示例8: SphinxClient

<?php

require "spec/fixtures/sphinxapi.php";
$cl = new SphinxClient();
$cl->UpdateAttributes('test1', array('group_id'), array(2 => array(1)));
开发者ID:alpbs,项目名称:sphinx,代码行数:5,代码来源:update_attributes.php

示例9: CsDataUpAttr

function CsDataUpAttr($ids, $index = '*', $attrs = array('status'), $values = 0, $timeout = 1, $host = 'localhost', $port = 9312)
{
    require C('INTERFACE_PATH') . 'coreseek/api/sphinxapi.php';
    $cl = new SphinxClient();
    $cl->SetServer($host, $port);
    $cl->SetConnectTimeout($timeout);
    foreach ($ids as $id) {
        $cl->UpdateAttributes($index, $attrs, array($id => array($values)));
    }
}
开发者ID:8yong8,项目名称:vshop,代码行数:10,代码来源:function.php

示例10: import_bibs

 /**
  * Does the actual import of bib records.  Called by the harvester.
  * It uses start and end parameters because this function can potentially be called by a
  * child process.
  *
  * @param int $start Bib number to start with
  * @param int $end Bib number to end with
  * @return array Array of information about the bibs imported
  */
 public function import_bibs($start, $end, $force = TRUE)
 {
     if (is_callable(array(__CLASS__ . '_hook', __FUNCTION__))) {
         eval('$hook = new ' . __CLASS__ . '_hook;');
         return $hook->{__FUNCTION__}($start, $end);
     }
     $db =& MDB2::connect($this->dsn);
     $couch = new couchClient($this->couchserver, $this->couchdatabase);
     $process_report['skipped'] = 0;
     $process_report['imported'] = 0;
     $utf = "SET NAMES 'utf8' COLLATE 'utf8_unicode_ci'";
     $utfprep = $db->query($utf);
     for ($i = $start; $i <= $end; $i++) {
         $sql = "SELECT * FROM locum_bib_items WHERE bnum = {$i}";
         $init_result = $db->query($sql);
         $init_bib_arr = $init_result->fetchAll(MDB2_FETCHMODE_ASSOC);
         try {
             $doc = $couch->getDoc((string) $i);
         } catch (Exception $e) {
             if ($e->getCode() == 404) {
                 // document doesn't exist. create a new one
                 $doc = new stdClass();
                 $doc->_id = (string) $i;
             } else {
                 // something probably wrong with the server. dump out
                 $this->putlog("Problem with CouchDB server for record {$i}. " . $e->getCode());
                 exit(1);
             }
         }
         if ($doc->protected != 1) {
             $bib = $this->locum_cntl->scrape_bib($i, $this->locum_config['api_config']['skip_covers']);
             if ($bib == FALSE || $bib == 'skip' || $bib['suppress'] == 1) {
                 if ($init_bib_arr) {
                     $sql_prep =& $db->prepare('UPDATE locum_bib_items SET active = ? WHERE bnum = ?', array('text', 'integer'));
                     $sql_prep->execute(array('0', $i));
                 }
                 if ($doc->active) {
                     $doc->active = 0;
                     $couch->storeDoc($doc);
                     require_once $this->locum_config['sphinx_config']['api_path'] . '/sphinxapi.php';
                     $cl = new SphinxClient();
                     $cl->SetServer($this->locum_config['sphinx_config']['server_addr'], (int) $this->locum_config['sphinx_config']['server_port']);
                     $cl->UpdateAttributes("bib_items_keyword,bib_items_author,bib_items_title,bib_items_subject,bib_items_callnum,bib_items_tags,bib_items_reviews", array("active"), array($i => array(0)));
                     $this->putlog("suppressed {$i}");
                 }
                 $process_report['skipped']++;
             } else {
                 if ($force || $doc->bib_lastupdate != $bib['bib_lastupdate']) {
                     $subj = $bib['subjects'];
                     $valid_vals = array('bib_created', 'bib_lastupdate', 'bib_prevupdate', 'bib_revs', 'lang', 'loc_code', 'mat_code', 'author', 'addl_author', 'title', 'title_medium', 'addl_title', 'edition', 'series', 'callnum', 'pub_info', 'pub_year', 'stdnum', 'upc', 'lccn', 'descr', 'notes', 'bnum', 'cover_img', 'non_romanized_title', 'non_romanized_author', 'genres', 'non_romanized_notes');
                     foreach ($bib as $bkey => $bval) {
                         if (in_array($bkey, $valid_vals)) {
                             if ($bval) {
                                 $doc->{$bkey} = $bval;
                             }
                             if (is_array($bval)) {
                                 if (count($bval) == 1) {
                                     $bval = $bval[0];
                                 } else {
                                     $bval = serialize($bval);
                                 }
                             }
                             $bib_values[$bkey] = $bval;
                         }
                     }
                     // unset items that are in couch but not mysql for now
                     unset($bib_values['non_romanized_title']);
                     unset($bib_values['non_romanized_author']);
                     unset($bib_values['non_romanized_notes']);
                     unset($bib_values['genres']);
                     if ($init_bib_arr) {
                         $bib_values['cover_img'] = $init_bib_arr[0]['cover_img'];
                     }
                     $bib_values['subjects_ser'] = serialize($subj);
                     $types = array('date', 'date', 'date', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'text', 'text', 'text', 'text', 'text', 'text', 'integer', 'text');
                     $sql_prep = $db->prepare('REPLACE INTO locum_bib_items VALUES (:bnum, :author, :addl_author, :title, :addl_title, :title_medium, :edition, :series, :callnum, :pub_info, :pub_year, :stdnum, :upc, :lccn, :descr, :notes, :subjects_ser, :lang, :loc_code, :mat_code, :cover_img, NOW(), :bib_created, :bib_lastupdate, :bib_prevupdate, :bib_revs, \'1\')');
                     $affrows = $sql_prep->execute($bib_values);
                     $doc->subjects = $subj;
                     $doc->active = 1;
                     if ($doc->upc == '000000000000') {
                         unset($doc->upc);
                     }
                     if (!$bib['pub_year']) {
                         unset($doc->pub_year);
                     }
                     $couch->storeDoc($doc);
                     $this->putlog("Importing bib # {$i} - {$bib['title']}");
                     $sql_prep->free();
                     /*
                               if (is_array($subj) && count($subj)) {
                                 foreach ($subj as $subj_heading) {
//.........这里部分代码省略.........
开发者ID:aadl,项目名称:locum,代码行数:101,代码来源:locum-server.php

示例11: updateAttr

 /**
  * update attr value
  * 更新属性值
  * @param $fields 需要修改的字段
  * $fields = array('age1','age2');
  * @param $values 要修改的值
  * $values = array(100004 => array(20,26));
  * 意思是把uid为100004的数据的属性age1改成20,age2改成26
  */
 public function updateAttr($fields, $values)
 {
     $index = $this->index;
     return parent::UpdateAttributes($index, $fields, $values);
 }
开发者ID:noikiy,项目名称:zays,代码行数:14,代码来源:search.class.php


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