-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelasticsearch.module
More file actions
40 lines (33 loc) · 1.07 KB
/
elasticsearch.module
File metadata and controls
40 lines (33 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
use Elastica\Client;
/**
* Implements hook_init().
*/
function elasticsearch_init(){
$libraries = libraries_get_libraries();
if (isset($libraries['Elastica'])) {
$elastica_path = libraries_get_path('Elastica') . DIRECTORY_SEPARATOR . 'lib';
set_include_path(get_include_path() . PATH_SEPARATOR . DRUPAL_ROOT . DIRECTORY_SEPARATOR . $elastica_path);
set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__) . '/../lib'));
spl_autoload_register('elasticsearch_autoload');
$client = new Client();
$index = $client->getIndex('test');
}
}
/**
* Implements hook_search_api_service_info().
*/
function elasticsearch_search_api_service_info() {
$services['elasticsearch_service'] = array(
'name' => t('elasticsearch service'),
'description' => t('Index items using elasticsearch.'),
'class' => 'ElasticsearchService',
);
return $services;
}
function elasticsearch_autoload($class) {
if (substr($class, 0, 8) == 'Elastica') {
$file = str_replace('\\', '/', $class) . '.php';
require_once $file;
}
}