Skip to content

Commit 2ac1fb0

Browse files
committed
Merge pull request #12 from mhh1422/master
Add index meta functions:
2 parents bffb9c1 + 588feb6 commit 2ac1fb0

File tree

2 files changed

+207
-1
lines changed

2 files changed

+207
-1
lines changed

ideh/classes.php

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,130 @@ public static function find($type, $id) {
123123

124124
}
125125

126+
/**
127+
* Retreives the meta data of an index
128+
* @param string|array $features a list of meta objects to fetch. null means
129+
* everything. Can be
130+
* * 1 string (i.e. '_settings'),
131+
* * csv (i.e. '_settings,_aliases'),
132+
* * array (i.e. ['_settings','_aliases']
133+
* @param array $options can contain:
134+
* ['ignore_unavailable']
135+
* (bool) Whether specified concrete indices should be ignored
136+
* when unavailable (missing or closed)
137+
* ['allow_no_indices']
138+
* (bool) Whether to ignore if a wildcard indices expression
139+
* resolves into no concrete indices. (This includes `_all`
140+
* string or when no indices have been specified)
141+
* ['expand_wildcards']
142+
* (enum) Whether to expand wildcard expression to concrete
143+
* indices that are open, closed or both.
144+
* ['local']
145+
* (bool) Return local information, do not retrieve the state
146+
* from master node (default: false)
147+
* @return array
148+
*/
149+
public function meta($feature = null, array $options = []) {
150+
151+
}
152+
153+
/**
154+
* Retreives the meta data of an index
155+
* @param string|array $features a list of meta objects to fetch. null means
156+
* everything. Can be
157+
* * 1 string (i.e. '_settings'),
158+
* * csv (i.e. '_settings,_aliases'),
159+
* * array (i.e. ['_settings','_aliases']
160+
* @param array $options can contain:
161+
* ['ignore_unavailable']
162+
* (bool) Whether specified concrete indices should be ignored
163+
* when unavailable (missing or closed)
164+
* ['allow_no_indices']
165+
* (bool) Whether to ignore if a wildcard indices expression
166+
* resolves into no concrete indices. (This includes `_all`
167+
* string or when no indices have been specified)
168+
* ['expand_wildcards']
169+
* (enum) Whether to expand wildcard expression to concrete
170+
* indices that are open, closed or both.
171+
* ['local']
172+
* (bool) Return local information, do not retrieve the state
173+
* from master node (default: false)
174+
* @return array
175+
*/
176+
public static function meta($feature = null, array $options = []) {
177+
178+
}
179+
180+
/**
181+
* Retreives just the settings of the index
182+
* @param array $options check _meta() for details
183+
* @return array
184+
*/
185+
public function metaSettings(array $options = []) {
186+
187+
}
188+
189+
/**
190+
* Retreives just the settings of the index
191+
* @param array $options check _meta() for details
192+
* @return array
193+
*/
194+
public static function metaSettings(array $options = []) {
195+
196+
}
197+
198+
/**
199+
* Retreives just the aliases of the index
200+
* @param array $options check _meta() for details
201+
* @return array
202+
*/
203+
public function metaAliases(array $options = []) {
204+
205+
}
206+
207+
/**
208+
* Retreives just the aliases of the index
209+
* @param array $options check _meta() for details
210+
* @return array
211+
*/
212+
public static function metaAliases(array $options = []) {
213+
214+
}
215+
216+
/**
217+
* Retreives just the warmers of the index
218+
* @param array $options check _meta() for details
219+
* @return array
220+
*/
221+
public function metaWarmers(array $options = []) {
222+
223+
}
224+
225+
/**
226+
* Retreives just the warmers of the index
227+
* @param array $options check _meta() for details
228+
* @return array
229+
*/
230+
public static function metaWarmers(array $options = []) {
231+
232+
}
233+
234+
/**
235+
* Retreives just the mappings of the index
236+
* @param array $options check _meta() for details
237+
* @return array
238+
*/
239+
public function metaMappings(array $options = []) {
240+
241+
}
242+
243+
/**
244+
* Retreives just the mappings of the index
245+
* @param array $options check _meta() for details
246+
* @return array
247+
*/
248+
public static function metaMappings(array $options = []) {
249+
250+
}
251+
126252
}

src/Query.php

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,88 @@ protected static function _allowPublicAccess() {
345345
return [
346346
'all',
347347
'query',
348-
'find'
348+
'find',
349+
'meta',
350+
'metaSettings',
351+
'metaAliases',
352+
'metaMappings',
353+
'metaWarmers'
349354
];
350355
}
351356

357+
/**
358+
* Retreives the meta data of an index
359+
* @param string|array $features a list of meta objects to fetch. null means
360+
* everything. Can be
361+
* * 1 string (i.e. '_settings'),
362+
* * csv (i.e. '_settings,_aliases'),
363+
* * array (i.e. ['_settings','_aliases']
364+
* @param array $options can contain:
365+
* ['ignore_unavailable']
366+
* (bool) Whether specified concrete indices should be ignored
367+
* when unavailable (missing or closed)
368+
* ['allow_no_indices']
369+
* (bool) Whether to ignore if a wildcard indices expression
370+
* resolves into no concrete indices. (This includes `_all`
371+
* string or when no indices have been specified)
372+
* ['expand_wildcards']
373+
* (enum) Whether to expand wildcard expression to concrete
374+
* indices that are open, closed or both.
375+
* ['local']
376+
* (bool) Return local information, do not retrieve the state
377+
* from master node (default: false)
378+
* @return array
379+
*/
380+
protected function _meta($features = null, array $options = []) {
381+
if ($features) {
382+
$features = join(',', array_map(function($item) {
383+
return '_' . strtolower(trim($item, '_'));
384+
}, is_scalar($features) ? explode(",", $features) : $features));
385+
}
386+
$options = ['index' => $this->index()] + $options + ($features ? ['feature' => $features] : []);
387+
$result = $this->client->indices()->get($options);
388+
$result = array_pop($result);
389+
return $result;
390+
}
391+
392+
/**
393+
* Retreives just the settings of the index
394+
* @param array $options check _meta() for details
395+
* @return array
396+
*/
397+
protected function _metaSettings(array $options = []) {
398+
$result = $this->_meta('_settings', $options);
399+
return array_pop($result);
400+
}
401+
402+
/**
403+
* Retreives just the aliases of the index
404+
* @param array $options check _meta() for details
405+
* @return array
406+
*/
407+
protected function _metaAliases(array $options = []) {
408+
$result = $this->_meta('_aliases', $options);
409+
return array_pop($result);
410+
}
411+
412+
/**
413+
* Retreives just the mappings of the index
414+
* @param array $options check _meta() for details
415+
* @return array
416+
*/
417+
protected function _metaMappings(array $options = []) {
418+
$result = $this->_meta('_mappings', $options);
419+
return array_pop($result);
420+
}
421+
422+
/**
423+
* Retreives just the warmers of the index
424+
* @param array $options check _meta() for details
425+
* @return array
426+
*/
427+
protected function _metaWarmers(array $options = []) {
428+
$result = $this->_meta('_warmers', $options);
429+
return array_pop($result);
430+
}
431+
352432
}

0 commit comments

Comments
 (0)