0
|
1 <?php
|
|
2
|
|
3 /**
|
|
4 * @file
|
|
5 * Dummy object to simulate a Solr Service
|
|
6 *
|
|
7 */
|
|
8 class DummySolr implements DrupalApacheSolrServiceInterface {
|
|
9
|
|
10 function getId() {
|
|
11 return __CLASS__;
|
|
12 }
|
|
13
|
|
14 function getFields($num_terms = 0) {
|
|
15 return (object) array(
|
|
16 'is_uid' =>
|
|
17 (object) array(
|
|
18 'type' => 'long',
|
|
19 'schema' => 'I-S----OF-----',
|
|
20 ),
|
|
21 'content' =>
|
|
22 (object) array(
|
|
23 'type' => 'text',
|
|
24 'schema' => 'ITS-V---------',
|
|
25 ),
|
|
26 'im_3_field_tags' =>
|
|
27 (object) array(
|
|
28 'type' => 'long',
|
|
29 'schema' => 'I-SM---OF-----',
|
|
30 'dynamicBase' => 'im_*',
|
|
31 ),
|
|
32 'entity_type' =>
|
|
33 (object) array(
|
|
34 'type' => 'string',
|
|
35 'schema' => 'I-S----OF----l',
|
|
36 ),
|
|
37 'ds_last_comment_or_change' =>
|
|
38 (object) array(
|
|
39 'type' => 'tdate',
|
|
40 'schema' => 'ITS----OF-----',
|
|
41 ),
|
|
42 'nodeaccess_ari4jj_node_access_example_view' =>
|
|
43 (object) array(
|
|
44 'type' => 'integer',
|
|
45 'schema' => 'I--M---OF-----',
|
|
46 'dynamicBase' => 'nodeaccess*',
|
|
47 ),
|
|
48 'entity_id' =>
|
|
49 (object) array(
|
|
50 'type' => 'tlong',
|
|
51 'schema' => 'ITS----OF-----',
|
|
52 ),
|
|
53 'ds_changed' =>
|
|
54 (object) array(
|
|
55 'type' => 'tdate',
|
|
56 'schema' => 'ITS----OF-----',
|
|
57 ),
|
|
58 'id' =>
|
|
59 (object) array(
|
|
60 'type' => 'string',
|
|
61 'schema' => 'I-S----OF----l',
|
|
62 ),
|
|
63 'timestamp' =>
|
|
64 (object) array(
|
|
65 'type' => 'date',
|
|
66 'schema' => 'I-S----OF----l',
|
|
67 ),
|
|
68 'label' =>
|
|
69 (object) array(
|
|
70 'type' => 'text',
|
|
71 'schema' => 'ITS-V--O------',
|
|
72 ),
|
|
73 'nodeaccess_ari4jj_node_access_example_edit' =>
|
|
74 (object) array(
|
|
75 'type' => 'integer',
|
|
76 'schema' => 'I--M---OF-----',
|
|
77 'dynamicBase' => 'nodeaccess*',
|
|
78 ),
|
|
79 'ds_created' =>
|
|
80 (object) array(
|
|
81 'type' => 'tdate',
|
|
82 'schema' => 'ITS----OF-----',
|
|
83 ),
|
|
84 'ss_name' =>
|
|
85 (object) array(
|
|
86 'type' => 'text',
|
|
87 'schema' => 'ITS-V---------',
|
|
88 ),
|
|
89 'path' =>
|
|
90 (object) array(
|
|
91 'type' => 'string',
|
|
92 'schema' => 'I-S----OF----l',
|
|
93 ),
|
|
94 'taxonomy_names' =>
|
|
95 (object) array(
|
|
96 'type' => 'text',
|
|
97 'schema' => 'IT-MV--O------',
|
|
98 ),
|
|
99 'bundle' =>
|
|
100 (object) array(
|
|
101 'type' => 'string',
|
|
102 'schema' => 'I-S----OF----l',
|
|
103 ),
|
|
104 'tid' =>
|
|
105 (object) array(
|
|
106 'type' => 'long',
|
|
107 'schema' => 'I-SM---OF-----',
|
|
108 ),
|
|
109 'is_tnid' =>
|
|
110 (object) array(
|
|
111 'type' => 'long',
|
|
112 'schema' => 'I-S----OF-----',
|
|
113 ),
|
|
114 'nodeaccess_ari4jj_node_access_example_author' =>
|
|
115 (object) array(
|
|
116 'type' => 'integer',
|
|
117 'schema' => 'I--M---OF-----',
|
|
118 'dynamicBase' => 'nodeaccess*',
|
|
119 ),
|
|
120 'tm_vid_1_names' =>
|
|
121 (object) array(
|
|
122 'type' => 'text',
|
|
123 'schema' => 'ITSMV---------',
|
|
124 'dynamicBase' => 'tm_*',
|
|
125 ),
|
|
126 'spell' =>
|
|
127 (object) array(
|
|
128 'type' => 'textSpell',
|
|
129 'schema' => 'ITSM----------',
|
|
130 ),
|
|
131 'site' =>
|
|
132 (object) array(
|
|
133 'type' => 'string',
|
|
134 'schema' => 'I-S----OF----l',
|
|
135 ),
|
|
136 'is_comment_count' =>
|
|
137 (object) array(
|
|
138 'type' => 'tint',
|
|
139 'schema' => 'ITS----OF-----',
|
|
140 ),
|
|
141 'bundle_name' =>
|
|
142 (object) array(
|
|
143 'type' => 'string',
|
|
144 'schema' => 'I-S----OF----l',
|
|
145 ),
|
|
146 'hash' =>
|
|
147 (object) array(
|
|
148 'type' => 'string',
|
|
149 'schema' => 'I-S----OF----l',
|
|
150 ),
|
|
151 'bs_status' =>
|
|
152 (object) array(
|
|
153 'type' => 'boolean',
|
|
154 'schema' => 'I-S----OF----l',
|
|
155 ),
|
|
156 'entity_id' =>
|
|
157 (object) array(
|
|
158 'type' => 'long',
|
|
159 'schema' => 'I-S----OF-----',
|
|
160 ),
|
|
161 'url' =>
|
|
162 (object) array(
|
|
163 'type' => 'string',
|
|
164 'schema' => 'I-S----OF----l',
|
|
165 ),
|
|
166 'nodeaccess_all' =>
|
|
167 (object) array(
|
|
168 'type' => 'integer',
|
|
169 'schema' => 'I--M---OF-----',
|
|
170 'dynamicBase' => 'nodeaccess*',
|
|
171 ),
|
|
172 'sort_name' =>
|
|
173 (object) array(
|
|
174 'type' => 'sortString',
|
|
175 'schema' => 'IT-----O-----l',
|
|
176 ),
|
|
177 'tags_a' =>
|
|
178 (object) array(
|
|
179 'type' => 'text',
|
|
180 'schema' => 'IT-----O------',
|
|
181 'dynamicBase' => 'tags_*',
|
|
182 ),
|
|
183 'bs_sticky' =>
|
|
184 (object) array(
|
|
185 'type' => 'boolean',
|
|
186 'schema' => 'I-S----OF----l',
|
|
187 ),
|
|
188 'bs_promote' =>
|
|
189 (object) array(
|
|
190 'type' => 'boolean',
|
|
191 'schema' => 'I-S----OF----l',
|
|
192 ),
|
|
193 'teaser' =>
|
|
194 (object) array(
|
|
195 'type' => 'text',
|
|
196 'schema' => '-TS-----------',
|
|
197 ),
|
|
198 'im_vid_1' =>
|
|
199 (object) array(
|
|
200 'type' => 'long',
|
|
201 'schema' => 'I-SM---OF-----',
|
|
202 'dynamicBase' => 'im_*',
|
|
203 ),
|
|
204 'bs_translate' =>
|
|
205 (object) array(
|
|
206 'type' => 'boolean',
|
|
207 'schema' => 'I-S----OF----l',
|
|
208 ),
|
|
209 'sort_label' =>
|
|
210 (object) array(
|
|
211 'type' => 'sortString',
|
|
212 'schema' => 'IT-----O-----l',
|
|
213 ),
|
|
214 'ss_language' =>
|
|
215 (object) array(
|
|
216 'type' => 'string',
|
|
217 'schema' => 'I-S----OF----l',
|
|
218 ),
|
|
219 'sm_vid_Tags' =>
|
|
220 (object) array(
|
|
221 'type' => 'string',
|
|
222 'schema' => 'I-SM---OF----l',
|
|
223 'dynamicBase' => 'sm_*',
|
|
224 ),
|
|
225 );
|
|
226 }
|
|
227
|
|
228 protected $last_search = array();
|
|
229
|
|
230 public function search($query = '', array $params = array(), $method = 'GET') {
|
|
231 $this->last_search = array('query' => $query, 'params' => $params, 'method' => $method);
|
|
232 $response = new stdClass();
|
|
233 $response->response = new stdClass();
|
|
234 $response->response->numFound = 0;
|
|
235 $response->response->docs = array();
|
|
236
|
|
237 return $response;
|
|
238 }
|
|
239
|
|
240 public function getLastSearch() {
|
|
241 return $this->last_search;
|
|
242 }
|
|
243
|
|
244 /**
|
|
245 * Call the /admin/ping servlet, to test the connection to the server.
|
|
246 *
|
|
247 * @param $timeout
|
|
248 * maximum time to wait for ping in seconds, -1 for unlimited (default 2).
|
|
249 * @return
|
|
250 * (float) seconds taken to ping the server, FALSE if timeout occurs.
|
|
251 */
|
|
252 function ping($timeout = 2) {
|
|
253 }
|
|
254
|
|
255 /**
|
|
256 * Get information about the Solr Core.
|
|
257 *
|
|
258 * @return
|
|
259 * (string) system info encoded in json
|
|
260 */
|
|
261 function getSystemInfo() {
|
|
262 }
|
|
263
|
|
264 /**
|
|
265 * Get meta-data about the index.
|
|
266 */
|
|
267 function getLuke($num_terms = 0) {
|
|
268 }
|
|
269
|
|
270 /**
|
|
271 * Get information about the Solr Core.
|
|
272 *
|
|
273 * Returns a Simple XMl document
|
|
274 */
|
|
275 function getStats() {
|
|
276 }
|
|
277
|
|
278 /**
|
|
279 * Get summary information about the Solr Core.
|
|
280 */
|
|
281 function getStatsSummary() {
|
|
282 }
|
|
283
|
|
284 /**
|
|
285 * Clear cached Solr data.
|
|
286 */
|
|
287 function clearCache() {
|
|
288 }
|
|
289
|
|
290 /**
|
|
291 * Constructor
|
|
292 *
|
|
293 * @param $url
|
|
294 * The URL to the Solr server, possibly including a core name. E.g. http://localhost:8983/solr/
|
|
295 * or https://search.example.com/solr/core99/
|
|
296 * @param $env_id
|
|
297 * The machine name of a corresponding saved configuration used for loading
|
|
298 * data like which facets are enabled.
|
|
299 */
|
|
300 function __construct($url, $env_id = NULL) {
|
|
301 }
|
|
302
|
|
303 /**
|
|
304 * Make a request to a servlet (a path) that's not a standard path.
|
|
305 *
|
|
306 * @param string $servlet
|
|
307 * A path to be added to the base Solr path. e.g. 'extract/tika'
|
|
308 *
|
|
309 * @param array $params
|
|
310 * Any request parameters when constructing the URL.
|
|
311 *
|
|
312 * @param array $options
|
|
313 * @see drupal_http_request() $options.
|
|
314 *
|
|
315 * @return
|
|
316 * response object
|
|
317 *
|
|
318 * @thows Exception
|
|
319 */
|
|
320 function makeServletRequest($servlet, $params = array(), $options = array()) {
|
|
321 }
|
|
322
|
|
323 /**
|
|
324 * Get the Solr url
|
|
325 *
|
|
326 * @return string
|
|
327 */
|
|
328 function getUrl() {
|
|
329 }
|
|
330
|
|
331 /**
|
|
332 * Set the Solr url.
|
|
333 *
|
|
334 * @param $url
|
|
335 *
|
|
336 * @return $this
|
|
337 */
|
|
338 function setUrl($url) {
|
|
339 }
|
|
340
|
|
341 /**
|
|
342 * Raw update Method. Takes a raw post body and sends it to the update service. Post body
|
|
343 * should be a complete and well formed xml document.
|
|
344 *
|
|
345 * @param string $rawPost
|
|
346 * @param float $timeout Maximum expected duration (in seconds)
|
|
347 *
|
|
348 * @return response object
|
|
349 *
|
|
350 * @throws Exception If an error occurs during the service call
|
|
351 */
|
|
352 function update($rawPost, $timeout = FALSE) {
|
|
353 }
|
|
354
|
|
355 /**
|
|
356 * Add an array of Solr Documents to the index all at once
|
|
357 *
|
|
358 * @param array $documents Should be an array of ApacheSolrDocument instances
|
|
359 * @param boolean $allowDups
|
|
360 * @param boolean $overwritePending
|
|
361 * @param boolean $overwriteCommitted
|
|
362 *
|
|
363 * @return response objecte
|
|
364 *
|
|
365 * @throws Exception If an error occurs during the service call
|
|
366 */
|
|
367 function addDocuments($documents, $overwrite = NULL, $commitWithin = NULL) {
|
|
368 }
|
|
369
|
|
370 /**
|
|
371 * Send a commit command. Will be synchronous unless both wait parameters are set to false.
|
|
372 *
|
|
373 * @param boolean $optimize Defaults to true
|
|
374 * @param boolean $waitFlush Defaults to true
|
|
375 * @param boolean $waitSearcher Defaults to true
|
|
376 * @param float $timeout Maximum expected duration (in seconds) of the commit operation on the server (otherwise, will throw a communication exception). Defaults to 1 hour
|
|
377 * @param boolean $softCommit optimize by using a softCommit
|
|
378 *
|
|
379 * @return response object
|
|
380 *
|
|
381 * @throws Exception If an error occurs during the service call
|
|
382 */
|
|
383 function commit($optimize = TRUE, $waitFlush = TRUE, $waitSearcher = TRUE, $timeout = 3600, $softCommit = FALSE) {
|
|
384 }
|
|
385
|
|
386 /**
|
|
387 * Create a delete document based on document ID
|
|
388 *
|
|
389 * @param string $id Expected to be utf-8 encoded
|
|
390 * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
|
|
391 *
|
|
392 * @return response object
|
|
393 *
|
|
394 * @throws Exception If an error occurs during the service call
|
|
395 */
|
|
396 function deleteById($id, $timeout = 3600) {
|
|
397 }
|
|
398
|
|
399 /**
|
|
400 * Create and post a delete document based on multiple document IDs.
|
|
401 *
|
|
402 * @param array $ids Expected to be utf-8 encoded strings
|
|
403 * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
|
|
404 *
|
|
405 * @return response object
|
|
406 *
|
|
407 * @throws Exception If an error occurs during the service call
|
|
408 */
|
|
409 function deleteByMultipleIds($ids, $timeout = 3600) {
|
|
410 }
|
|
411
|
|
412 /**
|
|
413 * Create a delete document based on a query and submit it
|
|
414 *
|
|
415 * @param string $rawQuery Expected to be utf-8 encoded
|
|
416 * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
|
|
417 * @return stdClass response object
|
|
418 *
|
|
419 * @throws Exception If an error occurs during the service call
|
|
420 */
|
|
421 function deleteByQuery($rawQuery, $timeout = 3600) {
|
|
422 }
|
|
423
|
|
424 /**
|
|
425 * Send an optimize command. Will be synchronous unless both wait parameters are set
|
|
426 * to false.
|
|
427 *
|
|
428 * @param boolean $waitFlush
|
|
429 * @param boolean $waitSearcher
|
|
430 * @param float $timeout Maximum expected duration of the commit operation on the server (otherwise, will throw a communication exception)
|
|
431 * @param boolean $softCommit optimize by using a softCommit
|
|
432 *
|
|
433 * @return response object
|
|
434 *
|
|
435 * @throws Exception If an error occurs during the service call
|
|
436 */
|
|
437 function optimize($waitFlush = TRUE, $waitSearcher = TRUE, $timeout = 3600, $softCommit = FALSE) {
|
|
438 }
|
|
439
|
|
440 /**
|
|
441 * Get the current solr version. This could be 1, 3 or 4
|
|
442 *
|
|
443 * @return int
|
|
444 * 1, 3 or 4. Does not give a more details version, for that you need
|
|
445 * to get the system info.
|
|
446 */
|
|
447 function getSolrVersion() {
|
|
448 }
|
|
449
|
|
450 /**
|
|
451 * Get query name.
|
|
452 */
|
|
453 function getName() {
|
|
454 }
|
|
455
|
|
456 /**
|
|
457 * Get query searcher name (for facetapi, views, pages, etc).
|
|
458 */
|
|
459 function getSearcher() {
|
|
460 }
|
|
461
|
|
462 /**
|
|
463 * Get context values.
|
|
464 */
|
|
465 function getContext() {
|
|
466 }
|
|
467
|
|
468 /**
|
|
469 * Set context value.
|
|
470 */
|
|
471 function addContext(array $context) {
|
|
472 }
|
|
473 }
|
|
474
|