1 | <?php |
||
39 | class SolrAdminService extends AbstractSolrService |
||
40 | { |
||
41 | const PLUGINS_SERVLET = 'admin/plugins'; |
||
42 | const LUKE_SERVLET = 'admin/luke'; |
||
43 | const SYSTEM_SERVLET = 'admin/system'; |
||
44 | const CORES_SERVLET = 'admin/cores'; |
||
45 | const FILE_SERVLET = 'admin/file'; |
||
46 | const SCHEMA_SERVLET = 'schema'; |
||
47 | const SYNONYMS_SERVLET = 'schema/analysis/synonyms/'; |
||
48 | const STOPWORDS_SERVLET = 'schema/analysis/stopwords/'; |
||
49 | |||
50 | /** |
||
51 | * Constructed servlet URL for plugin information |
||
52 | * |
||
53 | * @var string |
||
54 | */ |
||
55 | protected $_pluginsUrl; |
||
56 | |||
57 | /** |
||
58 | * Constructed servlet URL for Luke |
||
59 | * |
||
60 | * @var string |
||
61 | */ |
||
62 | protected $_lukeUrl; |
||
63 | |||
64 | /** |
||
65 | * @var array |
||
66 | */ |
||
67 | protected $lukeData = []; |
||
68 | |||
69 | /** |
||
70 | * @var string |
||
71 | */ |
||
72 | protected $_coresUrl; |
||
73 | |||
74 | |||
75 | protected $systemData = null; |
||
76 | |||
77 | protected $pluginsData = null; |
||
78 | |||
79 | /** |
||
80 | * @var string|null |
||
81 | */ |
||
82 | protected $solrconfigName; |
||
83 | |||
84 | /** |
||
85 | * @var string |
||
86 | */ |
||
87 | protected $_schemaUrl; |
||
88 | |||
89 | /** |
||
90 | * @var SchemaParser |
||
91 | */ |
||
92 | protected $schemaParser = null; |
||
93 | |||
94 | /** |
||
95 | * @var Schema |
||
96 | */ |
||
97 | protected $schema; |
||
98 | |||
99 | /** |
||
100 | * @var string |
||
101 | */ |
||
102 | protected $_synonymsUrl; |
||
103 | |||
104 | /** |
||
105 | * @var string |
||
106 | */ |
||
107 | protected $_stopWordsUrl; |
||
108 | |||
109 | /** |
||
110 | * @var SynonymParser |
||
111 | */ |
||
112 | protected $synonymParser = null; |
||
113 | |||
114 | /** |
||
115 | * @var StopWordParser |
||
116 | */ |
||
117 | protected $stopWordParser = null; |
||
118 | |||
119 | /** |
||
120 | * Constructor |
||
121 | * |
||
122 | * @param string $host Solr host |
||
123 | * @param string $port Solr port |
||
124 | * @param string $path Solr path |
||
125 | * @param string $scheme Scheme, defaults to http, can be https |
||
126 | * @param TypoScriptConfiguration $typoScriptConfiguration |
||
127 | * @param SynonymParser $synonymParser |
||
128 | * @param StopWordParser $stopWordParser |
||
129 | * @param SchemaParser $schemaParser |
||
130 | * @param SolrLogManager $logManager |
||
131 | */ |
||
132 | public function __construct( |
||
150 | |||
151 | protected function _initUrls() |
||
175 | |||
176 | |||
177 | /** |
||
178 | * Gets information about the plugins installed in Solr |
||
179 | * |
||
180 | * @return array A nested array of plugin data. |
||
181 | */ |
||
182 | public function getPluginsInformation() |
||
194 | |||
195 | /** |
||
196 | * get field meta data for the index |
||
197 | * |
||
198 | * @param int $numberOfTerms Number of top terms to fetch for each field |
||
199 | * @return array |
||
200 | */ |
||
201 | public function getFieldsMetaData($numberOfTerms = 0) |
||
205 | |||
206 | /** |
||
207 | * Retrieves meta data about the index from the luke request handler |
||
208 | * |
||
209 | * @param int $numberOfTerms Number of top terms to fetch for each field |
||
210 | * @return \Apache_Solr_Response Index meta data |
||
211 | */ |
||
212 | public function getLukeMetaData($numberOfTerms = 0) |
||
224 | |||
225 | /** |
||
226 | * Gets information about the Solr server |
||
227 | * |
||
228 | * @return array A nested array of system data. |
||
229 | */ |
||
230 | public function getSystemInformation() |
||
242 | |||
243 | /** |
||
244 | * Gets the name of the solrconfig.xml file installed and in use on the Solr |
||
245 | * server. |
||
246 | * |
||
247 | * @return string Name of the active solrconfig.xml |
||
248 | */ |
||
249 | public function getSolrconfigName() |
||
263 | |||
264 | /** |
||
265 | * Gets the Solr server's version number. |
||
266 | * |
||
267 | * @return string Solr version number |
||
268 | */ |
||
269 | public function getSolrServerVersion() |
||
276 | |||
277 | /** |
||
278 | * Reloads the current core |
||
279 | * |
||
280 | * @return \Apache_Solr_Response |
||
281 | */ |
||
282 | public function reloadCore() |
||
286 | |||
287 | /** |
||
288 | * Reloads a core of the connection by a given corename. |
||
289 | * |
||
290 | * @param string $coreName |
||
291 | * @return \Apache_Solr_Response |
||
292 | */ |
||
293 | public function reloadCoreByName($coreName) |
||
298 | |||
299 | /** |
||
300 | * Get the configured schema for the current core. |
||
301 | * |
||
302 | * @return Schema |
||
303 | */ |
||
304 | public function getSchema() |
||
313 | |||
314 | /** |
||
315 | * Get currently configured synonyms |
||
316 | * |
||
317 | * @param string $baseWord If given a base word, retrieves the synonyms for that word only |
||
318 | * @return array |
||
319 | */ |
||
320 | public function getSynonyms($baseWord = '') |
||
331 | |||
332 | /** |
||
333 | * Add list of synonyms for base word to managed synonyms map |
||
334 | * |
||
335 | * @param string $baseWord |
||
336 | * @param array $synonyms |
||
337 | * |
||
338 | * @return \Apache_Solr_Response |
||
339 | * |
||
340 | * @throws \Apache_Solr_InvalidArgumentException If $baseWord or $synonyms are empty |
||
341 | */ |
||
342 | public function addSynonym($baseWord, array $synonyms) |
||
349 | |||
350 | /** |
||
351 | * Remove a synonym from the synonyms map |
||
352 | * |
||
353 | * @param string $baseWord |
||
354 | * @return \Apache_Solr_Response |
||
355 | * @throws \Apache_Solr_InvalidArgumentException |
||
356 | */ |
||
357 | public function deleteSynonym($baseWord) |
||
366 | |||
367 | |||
368 | /** |
||
369 | * Get currently configured stop words |
||
370 | * |
||
371 | * @return array |
||
372 | */ |
||
373 | public function getStopWords() |
||
379 | |||
380 | /** |
||
381 | * Adds stop words to the managed stop word list |
||
382 | * |
||
383 | * @param array|string $stopWords string for a single word, array for multiple words |
||
384 | * @return \Apache_Solr_Response |
||
385 | * @throws \Apache_Solr_InvalidArgumentException If $stopWords is empty |
||
386 | */ |
||
387 | public function addStopWords($stopWords) |
||
394 | |||
395 | /** |
||
396 | * Deletes a words from the managed stop word list |
||
397 | * |
||
398 | * @param string $stopWord stop word to delete |
||
399 | * @return \Apache_Solr_Response |
||
400 | * @throws \Apache_Solr_InvalidArgumentException If $stopWords is empty |
||
401 | */ |
||
402 | public function deleteStopWord($stopWord) |
||
411 | |||
412 | /** |
||
413 | * @return void |
||
414 | */ |
||
415 | protected function initializeSynonymsUrl() |
||
422 | |||
423 | /** |
||
424 | * @return void |
||
425 | */ |
||
426 | protected function initializeStopWordsUrl() |
||
434 | } |
||
435 |