示例#1
0
 public function buildSearchIndex($commit = true, $create_docs = true)
 {
     if ($create_docs) {
         $this->storeDoc();
     }
     $solr = new Dase_Solr($this->db, $this->config);
     Dase_Log::debug(LOG_FILE, "built indexes for " . $this->serial_number);
     return $solr->buildItemIndex($this, $commit);
 }
示例#2
0
//$limit = 15;
if ($limit) {
    print "\nCurrently set to index most recent {$limit} items\n";
}
$cs = new Dase_DBO_Collection($db);
$cs->orderBy('id DESC');
foreach ($cs->find() as $c) {
    $c = clone $c;
    $colls[] = $c->ascii_id;
}
//can enter collections on command line
if (isset($argv[1])) {
    array_shift($argv);
    $colls = $argv;
}
$engine = new Dase_Solr($db, $config);
$i = 0;
foreach ($colls as $coll) {
    $c = Dase_DBO_Collection::get($db, $coll);
    if ($c) {
        foreach ($c->getItems($limit) as $item) {
            $i++;
            $item = clone $item;
            print $c->collection_name . ':' . $item->serial_number . ':' . $item->buildSearchIndex(false, false);
            print " {$i}\n";
            print " memory: " . memory_get_usage() . "\n";
        }
        print "\ncommitting indexes for {$c->collection_name} ";
        $engine->commit();
        print "...done\n\n";
    }
示例#3
0
 public function postToCommit($r)
 {
     $search_engine = new Dase_Solr($this->db, $this->config);
     $params['msg'] = $search_engine->commit();
     $r->renderRedirect('admin/tools', $params);
 }
示例#4
0
 public function getSearchItemAtom($r)
 {
     $r->checkCache();
     $search = new Dase_Solr($this->db, $this->config);
     //so we only get ONE record
     //$this->max =1;
     $search->prepareSearch($r, $this->start, $this->max, $this->num, $this->sort, $this->uid);
     $atom_feed = $search->getResultsAsItemAtom();
     $r->renderResponse($atom_feed);
 }
示例#5
0
 public function getSolrResponseXml($r)
 {
     $user = $r->getUser();
     if (!$user->can('read', $this->item)) {
         $r->renderError(401, 'user cannot read this item');
     }
     $ds = new Dase_Solr($this->db, $this->config);
     $r->renderResponse($ds->getSolrResponse($this->item->getUnique()));
 }
示例#6
0
 public function postToCommit($r)
 {
     $user = $r->getUser('http');
     if (!$user->can('write', $this->collection)) {
         $r->renderError(401, 'no go unauthorized');
     }
     $ds = new Dase_Solr($this->db, $this->config);
     if ('ok' == $ds->commit()) {
         $r->renderOk('commit successful');
     } else {
         $r->renderError(400, 'did not commit');
     }
 }
示例#7
0
 public function postToMetadata($r)
 {
     $user = $r->getUser();
     if (!$user->can('admin', $this->tag)) {
         $r->renderError(401, 'cannot post tag metadata');
     }
     $att_ascii = $r->get('ascii_id');
     foreach ($this->tag->getTagItems() as $tag_item) {
         $item = $tag_item->getItem();
         if ($item) {
             foreach ($r->get('value', true) as $val) {
                 $item->setValue($att_ascii, $val);
             }
             //do not commit
             $item->buildSearchIndex(false);
         }
     }
     $solr = new Dase_Solr($this->db, $this->config);
     $solr->commit();
     $r->renderRedirect('tag/' . $user->eid . '/' . $this->tag->ascii_id . '/list');
 }