@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function app_content($request, $args){ |
|
3 | +function app_content($request, $args) { |
|
4 | 4 | |
5 | 5 | global $ES; |
6 | 6 | $index = $args['index']; |
@@ -16,24 +16,24 @@ discard block |
||
16 | 16 | $params['sort'] = $sort; |
17 | 17 | $params['from'] = $from; |
18 | 18 | $params['size'] = $size; |
19 | - if (!empty($query)){ |
|
19 | + if (!empty($query)) { |
|
20 | 20 | $body = json_decode($query); |
21 | - if (json_last_error() == JSON_ERROR_NONE){ |
|
21 | + if (json_last_error() == JSON_ERROR_NONE) { |
|
22 | 22 | $params['body'] = $body; |
23 | 23 | } else { |
24 | 24 | $params['q'] = $query; |
25 | 25 | } |
26 | 26 | } |
27 | 27 | $results = $ES->search($params); |
28 | - foreach($results['hits']['hits'] as $doc){ |
|
28 | + foreach ($results['hits']['hits'] as $doc) { |
|
29 | 29 | $doc['_source']['_id'] = $doc['_id']; |
30 | 30 | $documents[] = $doc['_source']; |
31 | 31 | } |
32 | 32 | $params['search_type'] = 'count'; |
33 | 33 | $count = $ES->search($params); |
34 | 34 | $nof = 0; |
35 | - if(isset($count['hits']['total'])){ |
|
36 | - $nof = (int) $count['hits']['total']; |
|
35 | + if (isset($count['hits']['total'])) { |
|
36 | + $nof = (int) $count['hits']['total']; |
|
37 | 37 | } |
38 | - return ['app_title'=>$index."/".$type ,'data'=>['index' => $index, 'type' => $type, 'documents'=> $documents, 'from' => $from, 'nof'=>$nof, 'size' => $size,'sort'=>$sort, 'query'=>$query]]; |
|
38 | + return ['app_title'=>$index . "/" . $type, 'data'=>['index' => $index, 'type' => $type, 'documents'=> $documents, 'from' => $from, 'nof'=>$nof, 'size' => $size, 'sort'=>$sort, 'query'=>$query]]; |
|
39 | 39 | } |
@@ -1,19 +1,19 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function app_content($request, $args ) { |
|
3 | +function app_content($request, $args) { |
|
4 | 4 | |
5 | 5 | global $ES; |
6 | 6 | |
7 | 7 | $indices = $ES->indices()->getAliases(); |
8 | 8 | $indexes = []; |
9 | 9 | foreach ($indices as $index => $alieses) { |
10 | - if (strpos($index, ".") !==0 ){ |
|
10 | + if (strpos($index, ".") !== 0) { |
|
11 | 11 | $params['index'] = $index; |
12 | 12 | $index_data = []; |
13 | - $index_data['name']=$index; |
|
13 | + $index_data['name'] = $index; |
|
14 | 14 | $index_info = $ES->indices()->getMapping($params); |
15 | - foreach ( $index_info[$index]['mappings'] as $type => $type_info ) { |
|
16 | - if ( $type == '_default_' ) { continue; } |
|
15 | + foreach ($index_info[$index]['mappings'] as $type => $type_info) { |
|
16 | + if ($type == '_default_') { continue; } |
|
17 | 17 | $index_data['types'][] = $type; |
18 | 18 | } |
19 | 19 | $indexes[] = $index_data; |
@@ -7,10 +7,10 @@ discard block |
||
7 | 7 | |
8 | 8 | session_start(); |
9 | 9 | |
10 | -if(isset($_GET['ES_SERVER'])) { |
|
10 | +if (isset($_GET['ES_SERVER'])) { |
|
11 | 11 | $_SESSION['ES_SERVER'] = $_GET['ES_SERVER']; |
12 | 12 | } |
13 | -if(isset($_SESSION['ES_SERVER'])) { |
|
13 | +if (isset($_SESSION['ES_SERVER'])) { |
|
14 | 14 | $config['es_server'] = $_SESSION['ES_SERVER']; |
15 | 15 | } |
16 | 16 | |
@@ -19,5 +19,5 @@ discard block |
||
19 | 19 | $RSlim = new \RSlim\RSlim($config); |
20 | 20 | $RSlim->register("get", '/', 'es/root'); |
21 | 21 | $RSlim->register("get", "/{index}/{type}", "es/type"); |
22 | -$RSlim->register("get", "/delete/{index}/{type}/{id}", "es/doc.delete",'json'); |
|
22 | +$RSlim->register("get", "/delete/{index}/{type}/{id}", "es/doc.delete", 'json'); |
|
23 | 23 | $RSlim->run(); |
24 | 24 | \ No newline at end of file |