PluginProbe
ElasticPress / 5.3.5
ElasticPress v5.3.5
5.3.5 5.3.4 3.6.5 3.6.6 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.6.0 4.6.1 4.7.0 4.7.1 4.7.2 5.0.0 5.0.1 5.0.2 All 108 releases
elasticpress / includes / classes / StatusReport / Indices.php

Indices.php in ElasticPress 5.3.5, at includes/classes/StatusReport/Indices.php

106 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Indices report class
4 *
5 * @since 4.4.0
6 * @package elasticpress
7 */
8
9 namespace ElasticPress\StatusReport;
10
11 defined( 'ABSPATH' ) || exit;
12
13 /**
14 * Indices report class
15 *
16 * @package ElasticPress
17 */
18 class Indices extends Report {
19
20 /**
21 * Return the report title
22 *
23 * @return string
24 */
25 public function get_title(): string {
26 return __( 'Elasticsearch Indices', 'elasticpress' );
27 }
28
29 /**
30 * Return the report fields
31 *
32 * @return array
33 */
34 public function get_groups(): array {
35 $elasticsearch = \ElasticPress\Elasticsearch::factory();
36
37 $should_have_indices = $elasticsearch->get_index_names();
38 $indices_in_es = $elasticsearch->get_cluster_indices();
39 $indices_in_es_by_name = [];
40
41 if ( ! empty( $indices_in_es ) ) {
42 foreach ( $indices_in_es as $index ) {
43 $indices_in_es_by_name[ $index['index'] ] = $index;
44 }
45 }
46
47 $groups = [];
48
49 foreach ( $should_have_indices as $index_name ) {
50 if ( empty( $indices_in_es_by_name[ $index_name ] ) ) {
51 $groups[] = [
52 'title' => $index_name,
53 'fields' => [
54 [
55 'label' => 'Missing',
56 'value' => true,
57 ],
58 ],
59 ];
60 continue;
61 }
62
63 $index = $indices_in_es_by_name[ $index_name ];
64
65 $fields = array_reduce(
66 array_keys( $index ),
67 function ( $fields, $label ) use ( $index ) {
68 $fields[ $label ] = [
69 'label' => $label,
70 'value' => $index[ $label ],
71 ];
72 return $fields;
73 },
74 []
75 );
76
77 $fields['total_fields_limit'] = [
78 'label' => 'total_fields_limit',
79 'value' => $elasticsearch->get_index_total_fields_limit( $index['index'] ),
80 ];
81
82 $fields['analyzer_language'] = [
83 'label' => 'analyzer_language',
84 'value' => $elasticsearch->get_index_setting( $index['index'], 'index.analysis.analyzer.default.language' ),
85 ];
86
87 $fields['stop_language'] = [
88 'label' => 'stop_language',
89 'value' => $elasticsearch->get_index_setting( $index['index'], 'index.analysis.filter.ep_stop.stopwords' ),
90 ];
91
92 $fields['snowball_language'] = [
93 'label' => 'snowball_language',
94 'value' => $elasticsearch->get_index_setting( $index['index'], 'index.analysis.filter.ewp_snowball.language' ),
95 ];
96
97 $groups[] = [
98 'title' => $index['index'],
99 'fields' => $fields,
100 ];
101 }
102
103 return $groups;
104 }
105 }
106