Exemple #1
0
function scrubIndex($collection_ascii_id, $config, $db, $display = true)
{
    $solr_version = '2.2';
    $solr_base_url = $config->getSearch('solr_base_url');
    $solr_update_url = $solr_base_url . '/update';
    $j = 0;
    for ($i = 0; $i < 999999; $i++) {
        if (0 === $i % 100) {
            $solr_search_url = $solr_base_url . '/select/?q=c:' . $collection_ascii_id . '&version=' . $solr_version . '&rows=100&start=' . $i;
            list($http_code, $res) = Dase_Http::get($solr_search_url, null, null);
            $sx = simplexml_load_string($res);
            $num = 0;
            foreach ($sx->result as $result) {
                if (count($result->doc)) {
                    foreach ($result->doc as $doc) {
                        foreach ($doc->str as $str) {
                            if ('_id' == $str['name']) {
                                $j++;
                                if ($display) {
                                    print "START {$i} ({$j}) ";
                                }
                                $unique = (string) $str;
                                if (Dase_DBO_Item::getByUnique($db, $unique)) {
                                    if ($display) {
                                        print "FOUND {$unique}\n";
                                    }
                                } else {
                                    $num++;
                                    $delete_doc = '<delete><id>' . $unique . '</id></delete>';
                                    $resp = Dase_Http::post($solr_update_url, $delete_doc, null, null, 'text/xml');
                                    if ($display) {
                                        print "SCRUBBED {$unique}\n";
                                    }
                                }
                            }
                        }
                    }
                } else {
                    Dase_Http::post($solr_update_url, '<commit/>', null, null, 'text/xml');
                    return "scrubbed {$num} records";
                }
            }
        }
    }
}
Exemple #2
0
 public function postToSolr($item, $commit = true)
 {
     $start_check = Dase_Util::getTime();
     $start_get_doc = Dase_Util::getTime();
     $check_elapsed = round($start_get_doc - $start_check, 4);
     Dase_Log::debug(LOG_FILE, 'post to SOLR: ' . $this->solr_update_url . ' item ' . $item->getUnique());
     $solr_doc = $this->buildItemSolrDoc($item);
     //return $solr_doc;
     $start_index = Dase_Util::getTime();
     $get_doc_elapsed = round($start_index - $start_get_doc, 4);
     $resp = Dase_Http::post($this->solr_update_url, $solr_doc, null, null, 'text/xml');
     if ($commit) {
         Dase_Http::post($this->solr_update_url, '<commit/>', null, null, 'text/xml');
     }
     $end = Dase_Util::getTime();
     $index_elapsed = round($end - $start_index, 4);
     return $resp . ' check: ' . $check_elapsed . ' get_doc: ' . $get_doc_elapsed . ' index: ' . $index_elapsed;
 }
Exemple #3
0
<?php

include 'config.php';
$source = 'asian_studies';
$target = 'pkeane';
$c = Dase_DBO_Collection::get($db, $source);
foreach ($c->getItems() as $item) {
    $json_doc = $item->buildJson('http://dase.laits.utexas.edu');
    //print_r(json_decode($json_doc));
    $target_url = 'https://daseupload.laits.utexas.edu/collection/' . $target . '/ingester';
    print $target_url . "\n";
    $res = Dase_Http::post($target_url, $json_doc, 'pkeane', 'dupload', 'application/json');
    print_r($res);
}