|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
14
|
|
|
* |
|
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
|
16
|
|
|
* and is licensed under the MIT license. |
|
17
|
|
|
*/ |
|
18
|
|
|
namespace Elastification\Client\Response\Shared; |
|
19
|
|
|
|
|
20
|
|
|
use Elastification\Client\Response\Response; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Class AbstractSearchResponse |
|
24
|
|
|
* |
|
25
|
|
|
* @package Elastification\Client\Response\Shared |
|
26
|
|
|
* @author Daniel Wendlandt |
|
27
|
|
|
*/ |
|
28
|
|
|
abstract class AbstractSearchResponse extends Response |
|
29
|
|
|
{ |
|
30
|
|
|
const PROP_INDEX = '_index'; |
|
31
|
|
|
const PROP_TYPE = '_type'; |
|
32
|
|
|
const PROP_SHARDS = '_shards'; |
|
33
|
|
|
const PROP_TOOK = 'took'; |
|
34
|
|
|
const PROP_TIMED_OUT = 'timed_out'; |
|
35
|
|
|
const PROP_HITS = 'hits'; |
|
36
|
|
|
const PROP_HITS_TOTAL = 'total'; |
|
37
|
|
|
const PROP_HITS_MAX_SCORE = 'max_score'; |
|
38
|
|
|
const PROP_HITS_HITS = 'hits'; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Getter Method |
|
42
|
|
|
* |
|
43
|
|
|
* @return mixed |
|
44
|
|
|
* @author Daniel Wendlandt |
|
45
|
|
|
*/ |
|
46
|
6 |
|
public function getIndex() |
|
47
|
|
|
{ |
|
48
|
6 |
|
$this->processData(); |
|
49
|
|
|
|
|
50
|
6 |
|
return $this->get(self::PROP_INDEX); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Getter Method |
|
55
|
|
|
* |
|
56
|
|
|
* @return mixed |
|
57
|
|
|
* @author Daniel Wendlandt |
|
58
|
|
|
*/ |
|
59
|
6 |
|
public function getType() |
|
60
|
|
|
{ |
|
61
|
6 |
|
$this->processData(); |
|
62
|
|
|
|
|
63
|
6 |
|
return $this->get(self::PROP_TYPE); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Getter Method |
|
68
|
|
|
* |
|
69
|
|
|
* @return mixed |
|
70
|
|
|
* @author Daniel Wendlandt |
|
71
|
|
|
*/ |
|
72
|
6 |
|
public function took() |
|
73
|
|
|
{ |
|
74
|
6 |
|
$this->processData(); |
|
75
|
|
|
|
|
76
|
6 |
|
return $this->get(self::PROP_TOOK); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Getter Method |
|
81
|
|
|
* |
|
82
|
|
|
* @return mixed |
|
83
|
|
|
* @author Daniel Wendlandt |
|
84
|
|
|
*/ |
|
85
|
6 |
|
public function timedOut() |
|
86
|
|
|
{ |
|
87
|
6 |
|
$this->processData(); |
|
88
|
|
|
|
|
89
|
6 |
|
return $this->get(self::PROP_TIMED_OUT); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Getter Method |
|
94
|
|
|
* |
|
95
|
|
|
* @return mixed |
|
96
|
|
|
* @author Daniel Wendlandt |
|
97
|
|
|
*/ |
|
98
|
6 |
|
public function getShards() |
|
99
|
|
|
{ |
|
100
|
6 |
|
$this->processData(); |
|
101
|
|
|
|
|
102
|
6 |
|
return $this->get(self::PROP_SHARDS); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* Getter Method |
|
107
|
|
|
* |
|
108
|
|
|
* @return mixed |
|
109
|
|
|
* @author Daniel Wendlandt |
|
110
|
|
|
*/ |
|
111
|
36 |
|
public function getHits() |
|
112
|
|
|
{ |
|
113
|
36 |
|
$this->processData(); |
|
114
|
|
|
|
|
115
|
6 |
|
return $this->get(self::PROP_HITS); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* Getter Method |
|
120
|
|
|
* |
|
121
|
|
|
* @return mixed |
|
122
|
|
|
* @author Daniel Wendlandt |
|
123
|
|
|
*/ |
|
124
|
9 |
|
public function totalHits() |
|
125
|
|
|
{ |
|
126
|
9 |
|
return $this->getHitsProperty(self::PROP_HITS_TOTAL); |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
/** |
|
130
|
|
|
* Getter Method |
|
131
|
|
|
* |
|
132
|
|
|
* @return mixed |
|
133
|
|
|
* @author Daniel Wendlandt |
|
134
|
|
|
*/ |
|
135
|
9 |
|
public function maxScoreHits() |
|
136
|
|
|
{ |
|
137
|
9 |
|
return $this->getHitsProperty(self::PROP_HITS_MAX_SCORE); |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* Getter Method |
|
142
|
|
|
* |
|
143
|
|
|
* @return mixed |
|
144
|
|
|
* @author Daniel Wendlandt |
|
145
|
|
|
*/ |
|
146
|
9 |
|
public function getHitsHits() |
|
147
|
|
|
{ |
|
148
|
9 |
|
return $this->getHitsProperty(self::PROP_HITS_HITS)->getGatewayValue(); |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
/** |
|
152
|
|
|
* Getter Method |
|
153
|
|
|
* |
|
154
|
|
|
* @param string $property |
|
155
|
|
|
* |
|
156
|
|
|
* @return mixed |
|
157
|
|
|
* @author Daniel Wendlandt |
|
158
|
|
|
*/ |
|
159
|
27 |
|
protected function getHitsProperty($property) |
|
160
|
|
|
{ |
|
161
|
27 |
|
$this->processData(); |
|
162
|
|
|
|
|
163
|
27 |
|
return $this->data[self::PROP_HITS][$property]; |
|
164
|
|
|
} |
|
165
|
|
|
} |
|
166
|
|
|
|