Skip to content

Commit 32fdf7b

Browse files
author
Raymond Julin
committed
Minor fixes
1 parent e50ee4d commit 32fdf7b

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

ElasticSearchClient.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ public function index($document, $id=false) {
8282
* @param array $document
8383
*/
8484
public function search($query) {
85-
return $this->transport->search($query);
85+
$start = $this->getMicroTime();
86+
$result = $this->transport->search($query);
87+
$result['time'] = $this->getMicroTime() - $start;
88+
return $result;
8689
}
8790

8891
/**
@@ -105,4 +108,10 @@ public function delete($id=false) {
105108
public function deleteByQuery($query) {
106109
return $this->transport->deleteByQuery($query);
107110
}
111+
112+
private function getMicroTime() {
113+
list($usec, $sec) = explode(" ", microtime());
114+
return ((float)$usec + (float)$sec);
115+
}
116+
108117
}

lib/builder/ElasticSearchDSLBuilder.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class ElasticSearchDSLBuilder {
3232
* @param array $options
3333
*/
3434
public function __construct(array $options=array()) {
35+
foreach ($options as $key => $value)
36+
$this->$key = $value;
3537
}
3638

3739
/**
@@ -41,7 +43,8 @@ public function __construct(array $options=array()) {
4143
* @param array $options
4244
*/
4345
public function query(array $options=array()) {
44-
$this->query = new ElasticSearchDSLBuilderQuery($options);
46+
if (!($this->query instanceof ElasticSearchDSLBuilderQuery))
47+
$this->query = new ElasticSearchDSLBuilderQuery($options);
4548
return $this->query;
4649
}
4750

@@ -52,6 +55,10 @@ public function query(array $options=array()) {
5255
*/
5356
public function build() {
5457
$built = array();
58+
if ($this->from != null)
59+
$built['from'] = $this->from;
60+
if ($this->size != null)
61+
$built['size'] = $this->size;
5562
if (!$this->query)
5663
throw new Exception("Query must be specified");
5764
else

0 commit comments

Comments
 (0)