1 | <?php |
||
5 | class Hit |
||
6 | { |
||
7 | const SOURCE_DATA_KEY = '_source'; |
||
8 | const INDEX_DATA_KEY = '_index'; |
||
9 | const TYPE_DATA_KEY = '_type'; |
||
10 | const SCORE_DATA_KEY = '_score'; |
||
11 | const ID_DATA_KEY = '_id'; |
||
12 | const EXPLANATION_DATA_KEY = '_explanation'; |
||
13 | const VERSION_DATA_KEY = '_version'; |
||
14 | const SORT_DATA_KEY = 'sort'; |
||
15 | |||
16 | const FIELDS_DATA_KEY = 'fields'; |
||
17 | |||
18 | |||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $hitDataKey = self::SOURCE_DATA_KEY; |
||
23 | |||
24 | /** |
||
25 | * @var array |
||
26 | */ |
||
27 | protected $data; |
||
28 | |||
29 | /** |
||
30 | * @param array $hit |
||
31 | */ |
||
32 | public function __construct(array $hit) |
||
43 | |||
44 | /** |
||
45 | * @return string|null |
||
46 | */ |
||
47 | public function getIndexName() |
||
52 | |||
53 | /** |
||
54 | * @return string|null |
||
55 | */ |
||
56 | public function getTypeName() |
||
61 | |||
62 | /** |
||
63 | * @return int|null |
||
64 | */ |
||
65 | public function getScore() |
||
70 | |||
71 | |||
72 | /** |
||
73 | * @return array|null |
||
74 | */ |
||
75 | public function getExplanation() |
||
80 | |||
81 | /** |
||
82 | * @return int|string|null |
||
83 | */ |
||
84 | public function getId() |
||
89 | |||
90 | /** |
||
91 | * @return int|string|null |
||
92 | */ |
||
93 | public function getVersion() |
||
98 | |||
99 | /** |
||
100 | * Returns array of all hit metadata. |
||
101 | * |
||
102 | * @return array|null |
||
103 | */ |
||
104 | public function getMetadata() |
||
116 | |||
117 | /** |
||
118 | * @return array|null |
||
119 | */ |
||
120 | public function getFields() |
||
125 | |||
126 | |||
127 | /** |
||
128 | * Returns the _source data. |
||
129 | * |
||
130 | * @return array|null |
||
131 | */ |
||
132 | public function getSource() |
||
137 | |||
138 | /** |
||
139 | * @return array |
||
140 | */ |
||
141 | public function getRawData() |
||
145 | |||
146 | /** |
||
147 | * Returns value used for sorting or array of all if index is null. |
||
148 | * |
||
149 | * Returns null if not available. |
||
150 | * |
||
151 | * @param int|null $index |
||
152 | * @return mixed|null |
||
153 | */ |
||
154 | public function getSortValue($index = null) |
||
170 | |||
171 | /** |
||
172 | * Returns a source data piece. |
||
173 | * |
||
174 | * @param string $name |
||
175 | * @return mixed |
||
176 | */ |
||
177 | public function __get($name) |
||
185 | |||
186 | /** |
||
187 | * @param string $name |
||
188 | * @return bool |
||
189 | */ |
||
190 | public function __isset($name) |
||
194 | } |
||
195 |