@@ -40,7 +40,7 @@ |
||
40 | 40 | if (isset($query['fields'], $query['fields']['_percolator_document_slot'])) { |
41 | 41 | foreach ($query['fields']['_percolator_document_slot'] as $d) { |
42 | 42 | if (isset($this->array[$d-1])) { |
43 | - $this->array[$d-1]['queries'][] =$query; |
|
43 | + $this->array[$d-1]['queries'][] = $query; |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | } |
@@ -24,17 +24,17 @@ |
||
24 | 24 | { |
25 | 25 | if (isset($this->cluster)) { |
26 | 26 | if (isset($params['node'])) { |
27 | - return parent::setBody(['query' => "JOIN CLUSTER ".$this->cluster." AT '".$params['node']."'"]); |
|
27 | + return parent::setBody(['query' => "JOIN CLUSTER " . $this->cluster . " AT '" . $params['node'] . "'"]); |
|
28 | 28 | } else { |
29 | - $options =[]; |
|
29 | + $options = []; |
|
30 | 30 | if (isset($params['path'])) { |
31 | - $options[] = "'".$params['path']. "' AS path"; |
|
31 | + $options[] = "'" . $params['path'] . "' AS path"; |
|
32 | 32 | } |
33 | 33 | if (isset($params['nodes'])) { |
34 | - $options[] = "'".$params['nodes']. "' AS nodes"; |
|
34 | + $options[] = "'" . $params['nodes'] . "' AS nodes"; |
|
35 | 35 | } |
36 | - return parent::setBody(['query' => "JOIN CLUSTER ".$this->cluster. |
|
37 | - ((count($options)>0)?" ".implode(',', $options):"")]); |
|
36 | + return parent::setBody(['query' => "JOIN CLUSTER " . $this->cluster . |
|
37 | + ((count($options) > 0) ? " " . implode(',', $options) : "")]); |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | throw new RuntimeException('Cluster name is missing.'); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | public function addDocument($data, $id = 0) |
54 | 54 | { |
55 | 55 | if (is_object($data)) { |
56 | - $data = (array) $data; |
|
56 | + $data = (array)$data; |
|
57 | 57 | } elseif (is_string($data)) { |
58 | 58 | $data = json_decode($data, true); |
59 | 59 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $toinsert = []; |
77 | 77 | foreach ($documents as $document) { |
78 | 78 | if (is_object($document)) { |
79 | - $document = (array) $document; |
|
79 | + $document = (array)$document; |
|
80 | 80 | } elseif (is_string($document)) { |
81 | 81 | $document = json_decode($document, true); |
82 | 82 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | public function replaceDocument($data, $id) |
167 | 167 | { |
168 | 168 | if (is_object($data)) { |
169 | - $data = (array) $data; |
|
169 | + $data = (array)$data; |
|
170 | 170 | } elseif (is_string($data)) { |
171 | 171 | $data = json_decode($data, true); |
172 | 172 | } |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $toreplace = []; |
189 | 189 | foreach ($documents as $document) { |
190 | 190 | if (is_object($document)) { |
191 | - $document = (array) $document; |
|
191 | + $document = (array)$document; |
|
192 | 192 | } elseif (is_string($document)) { |
193 | 193 | $document = json_decode($document, true); |
194 | 194 | } |
@@ -34,20 +34,20 @@ |
||
34 | 34 | $options = ""; |
35 | 35 | if (isset($params['settings'])) { |
36 | 36 | foreach ($params['settings'] as $name => $value) { |
37 | - $options.=" ".$name." = '".$value."'"; |
|
37 | + $options .= " " . $name . " = '" . $value . "'"; |
|
38 | 38 | if (is_array($value)) { |
39 | 39 | foreach ($value as $v) { |
40 | - $options.=" ".$name." = '".$v."'"; |
|
40 | + $options .= " " . $name . " = '" . $v . "'"; |
|
41 | 41 | } |
42 | 42 | } else { |
43 | - $options.=" ".$name." = '".$value."'"; |
|
43 | + $options .= " " . $name . " = '" . $value . "'"; |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | } |
47 | - return parent::setBody(['query' => "CREATE TABLE ". |
|
48 | - (isset($params['silent']) && $params['silent']===true?' IF NOT EXISTS ':''). |
|
49 | - $this->index. |
|
50 | - (count($columns)>0?"(".implode(",", $columns).")":" ") |
|
47 | + return parent::setBody(['query' => "CREATE TABLE " . |
|
48 | + (isset($params['silent']) && $params['silent'] === true ? ' IF NOT EXISTS ' : '') . |
|
49 | + $this->index . |
|
50 | + (count($columns) > 0 ? "(" . implode(",", $columns) . ")" : " ") |
|
51 | 51 | .$options]); |
52 | 52 | } |
53 | 53 | throw new RuntimeException('Index name is missing.'); |
@@ -9,6 +9,6 @@ |
||
9 | 9 | { |
10 | 10 | public function __construct($keywords, $fields) |
11 | 11 | { |
12 | - $this->params['match'] =[$fields => $keywords]; |
|
12 | + $this->params['match'] = [$fields => $keywords]; |
|
13 | 13 | } |
14 | 14 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | { |
31 | 31 | $connection = $this->getConnection(); |
32 | 32 | $conn = $this->getCurlConnection($connection->getConfig('persistent')); |
33 | - $url = $this->scheme.'://'.$connection->getHost().':'.$connection->getPort(); |
|
33 | + $url = $this->scheme . '://' . $connection->getHost() . ':' . $connection->getPort(); |
|
34 | 34 | $endpoint = $request->getPath(); |
35 | 35 | $url .= $endpoint; |
36 | 36 | $url = $this->setupURI($url, $request->getQuery()); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | curl_setopt($conn, CURLOPT_CUSTOMREQUEST, $method); |
57 | 57 | curl_setopt($conn, CURLOPT_HTTPHEADER, $headers); |
58 | 58 | |
59 | - if ($connection->getConnectTimeout()>0) { |
|
59 | + if ($connection->getConnectTimeout() > 0) { |
|
60 | 60 | curl_setopt($conn, CURLOPT_CONNECTTIMEOUT, $connection->getConnectTimeout()); |
61 | 61 | } |
62 | 62 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | curl_setopt( |
66 | 66 | $conn, |
67 | 67 | CURLOPT_USERPWD, |
68 | - $connection->getConfig('username').":".$connection->getConfig('password') |
|
68 | + $connection->getConfig('username') . ":" . $connection->getConfig('password') |
|
69 | 69 | ); |
70 | 70 | } |
71 | 71 | if ($connection->getConfig('proxy') !== null) { |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | 'body' => $request->getBody() |
99 | 99 | ]); |
100 | 100 | //hard error |
101 | - if ($errorno>0) { |
|
101 | + if ($errorno > 0) { |
|
102 | 102 | $error = curl_error($conn); |
103 | 103 | |
104 | 104 | self::$curl = null; |
@@ -121,17 +121,17 @@ discard block |
||
121 | 121 | public function highlight($fields = [], $settings = []): self |
122 | 122 | { |
123 | 123 | |
124 | - if (count($fields) === 0 && count($settings)===0) { |
|
125 | - $this->params['highlight'] = new \stdClass(); |
|
124 | + if (count($fields) === 0 && count($settings) === 0) { |
|
125 | + $this->params['highlight'] = new \stdClass(); |
|
126 | 126 | return $this; |
127 | 127 | } |
128 | 128 | $this->params['highlight'] = []; |
129 | 129 | if (count($fields) > 0) { |
130 | - $this->params['highlight']['fields'] =$fields; |
|
130 | + $this->params['highlight']['fields'] = $fields; |
|
131 | 131 | } |
132 | - if (count($settings)>0) { |
|
132 | + if (count($settings) > 0) { |
|
133 | 133 | foreach ($settings as $name => $value) { |
134 | - $this->params['highlight'][$name] =$value; |
|
134 | + $this->params['highlight'][$name] = $value; |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | return $this; |
@@ -196,9 +196,9 @@ discard block |
||
196 | 196 | |
197 | 197 | if ($boolean === self::FILTER_AND) { |
198 | 198 | $this->query->must($attr); |
199 | - } else if($boolean === self::FILTER_OR) { |
|
199 | + } else if ($boolean === self::FILTER_OR) { |
|
200 | 200 | $this->query->should($attr); |
201 | - } else if($boolean === self::FILTER_NOT) { |
|
201 | + } else if ($boolean === self::FILTER_NOT) { |
|
202 | 202 | $this->query->mustNot($attr); |
203 | 203 | } |
204 | 204 | |
@@ -237,10 +237,10 @@ discard block |
||
237 | 237 | $group = $field; |
238 | 238 | } |
239 | 239 | $terms = ['field'=>$field]; |
240 | - if ($limit !==null) { |
|
240 | + if ($limit !== null) { |
|
241 | 241 | $terms['size'] = $limit; |
242 | 242 | } |
243 | - $this->params['aggs'][$group] =['terms' =>$terms]; |
|
243 | + $this->params['aggs'][$group] = ['terms' =>$terms]; |
|
244 | 244 | return $this; |
245 | 245 | } |
246 | 246 |