Example #1
0
 function delete($key)
 {
     $parts = parent::getUrlParts();
     if (!$this->authApiKey($parts[5], $key)) {
         $response['success'] = false;
         $response['message'] = "Not the right key.";
         echo json_encode($response);
         die;
     }
     $index = $parts[5] . "_" . $parts[6];
     $ch = curl_init("http://localhost:9200/{$index}");
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
     //curl_setopt($ch, CURLOPT_POSTFIELDS, $map);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
     $buffer = curl_exec($ch);
     curl_close($ch);
     return $buffer;
 }
Example #2
0
 function search($q, $call_back, $size, $pretty, $call_counter = false)
 {
     $parts = parent::getUrlParts();
     $indices = explode(",", $parts[6]);
     foreach ($indices as $v) {
         $arr[] = $parts[5] . "_" . $v;
     }
     $index = implode(",", $arr);
     $ch = curl_init("http://localhost:9200/{$index}/{$parts[7]}/_search?pretty={$pretty}&size={$size}");
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
     curl_setopt($ch, CURLOPT_POSTFIELDS, urldecode($q));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
     $buffer = curl_exec($ch);
     curl_close($ch);
     if ($call_counter) {
         //$obj->call_counter = (int)$call_counter;
     }
     $json = $call_back ? $call_back . "(" . $buffer . ")" : $buffer;
     return $json;
 }
Example #3
0
 function bulk()
 {
     $parts = Controller::getUrlParts();
     if (!$this->authApiKey($parts[5], $_GET['key'])) {
         $response['success'] = false;
         $response['message'] = "Not the right key.";
         echo json_encode($response);
         die;
     }
     if (sizeof($parts) < 9 || $parts[8] == "") {
         $response['success'] = false;
         $response['message'] = "The URI must be in this form: /api/v1/elasticsearch/bulk/[user]/[index]/[type]/[id]?q=[SELECT query]";
         echo json_encode($response);
         die;
     }
     //$postgisdb = $argv[1];
     $api = new Sql_to_es();
     $api->execQuery("set client_encoding='UTF8'", "PDO");
     //$api->sql($argv[5], $argv[2], $argv[3], $argv[4]);
     echo $api->sql(rawurldecode($_GET['q']), $parts[6], $parts[7], $parts[8], $parts[5]);
 }
Example #4
0
<?php

set_time_limit(0);
include '../../../conf/main.php';
include "inc/controller.php";
include 'model/settings_viewer.php';
$parts = Controller::getUrlParts();
switch ($parts[4]) {
    case "search":
        include 'search_c.php';
        $_GET['size'] = $_GET['size'] ? $_GET['size'] : 10;
        $_GET['pretty'] = $_GET['pretty'] || $_GET['pretty'] == "true" ? $_GET['pretty'] : "false";
        echo Search_c::search($_GET['q'], $_GET['jsonp_callback'], $_GET['size'], $_GET['pretty']);
        break;
    case "bulk":
        include 'bulk_c.php';
        $api = new Bulk_c();
        $api->bulk();
        break;
    case "map":
        include 'map_c.php';
        $api = new Map_c();
        // Set up out PUT variables
        parse_str(file_get_contents('php://input'), $_PUT);
        echo $api->map($_PUT['map'], $_PUT['key']);
        break;
    case "delete":
        include 'delete_c.php';
        $api = new Delete_c();
        // Set up out PUT variables
        parse_str(file_get_contents('php://input'), $_DELETE);