Example #1
0
 function run_data($old_index = "percolate_index_v6", $page = 1, $size = 1000)
 {
     ini_set("memory_limit", "20480M");
     $search_params = array('index' => $old_index, 'type' => ".percolator", 'size' => $size, 'from' => ($page - 1) * $size);
     $search_data = $this->elasticsearch->search($search_params);
     if (empty($search_data['data']['hits']['hits'])) {
         echo "no data";
         exit;
     }
     $i = 1;
     foreach ($search_data['data']['hits']['hits'] as $key => $val) {
         $uid = $val['_source']['uid'];
         $new_index = get_index_name($uid);
         $import_data['index'] = $new_index;
         $import_data['type'] = ".percolator";
         $import_data['id'] = strtolower($val['_id']);
         $import_data['body']['query'] = $val['_source']['query'];
         $import_data['body']['uid'] = $val['_source']['uid'];
         $import_data['body']['keyword'] = strtolower($val['_source']['keyword']);
         $import_data['body']['dy_type'] = $val['_source']['dy_type'];
         $import_data['body']['quite_time'] = $val['_source']['quite_time'];
         $import_data['body']['is_push'] = $val['_source']['is_push'];
         $import_data['body']['mrjx'] = $val['_source']['mrjx'];
         $import_data['body']['open_quite_time'] = $val['_source']['open_quite_time'];
         $import_data['body']['channel'] = $val['_source']['channel'];
         $import_data['body']['add_time'] = $val['_source']['add_time'];
         $import_data['body']['article_type'] = $val['_source']['channel'];
         $flag = $this->elasticsearch->index($import_data);
         if (empty($flag['error_msg'])) {
             echo "success ({$i}/{$size}) \n";
         } else {
             echo "error ({$i}/{$size}) \n";
             #print_r($flag['error_msg']);
         }
         $i++;
         unset($search_data['data']['hits']['hits'][$key]);
     }
     unset($search_data);
 }
$graph->xaxis->SetTextTickInterval(6);
$graph->xaxis->SetTextLabelInterval(6);
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetLabelAngle(90);
$rgb = new RGB();
$i = 0;
foreach ($datay as $dy) {
    // Create a red line plot
    $p[$i] = new LinePlot($dy);
    reset($rgb->rgb_table);
    for ($j = 0; $j <= $i; $j += 1) {
        for ($k = 0; $k <= 10; $k++) {
            next($rgb->rgb_table);
        }
        if (current($rgb->rgb_table) == "") {
            reset($rgb->rgb_table);
        }
    }
    $p[$i]->SetColor(current($rgb->rgb_table));
    $p[$i]->SetLegend(get_index_name($i));
    // The order the plots are added determines who's ontop
    $graph->Add($p[$i]);
    // $graph->Add($b1);
    #$i++;
    #echo "<pre>"; print_r($dy); echo "</pre>";
    $i++;
}
// Finally output the  image
$graph->Stroke();
ob_end_flush();
exit;