diff --git a/example/config.json b/example/config.json index 0ea4401..686738c 100644 --- a/example/config.json +++ b/example/config.json @@ -7,18 +7,22 @@ "username":"", "password":"" }, - "manticore": + "index": { - "name":"kvazar", - "host":"127.0.0.1", - "port":9308, - "meta": + "manticore": { - "morphology":"stem_cz,stem_enru", - "index_exact_words":1, - "html_strip":1, - "min_word_len":3, - "min_prefix_len":3 - } + "name":"kvazar", + "host":"127.0.0.1", + "port":9308, + "meta": + { + "morphology":"stem_cz,stem_enru", + "index_exact_words":1, + "html_strip":1, + "min_word_len":3, + "min_prefix_len":3 + } + }, + "driver":"manticore" } } \ No newline at end of file diff --git a/src/index.php b/src/index.php index 4fd1ad1..40d7761 100644 --- a/src/index.php +++ b/src/index.php @@ -12,9 +12,6 @@ if (false === sem_acquire($semaphore, true)) ); } -// Load dependencies -require_once __DIR__ . '/../vendor/autoload.php'; - // Init config if (!file_exists(__DIR__ . '/../config.json')) { @@ -29,25 +26,41 @@ $config = json_decode( ) ); +// Load dependencies +require_once __DIR__ . '/../vendor/autoload.php'; + // Init index -try +switch ($config->index->driver) { - $index = new \Kvazar\Index\Manticore( - (string) $config->manticore->name, - (array) $config->manticore->meta, - (string) $config->manticore->host, - (int) $config->manticore->port - ); -} + case 'manticore': -catch (Exception $exception) -{ - exit( - print_r( - $exception, - true - ) - ); + try + { + $index = new \Kvazar\Index\Manticore( + (string) $config->index->manticore->name, + (array) $config->index->manticore->meta, + (string) $config->index->manticore->host, + (int) $config->index->manticore->port + ); + } + + catch (Exception $exception) + { + exit( + print_r( + $exception, + true + ) + ); + } + + break; + + default: + + exit( + _('Undefined index driver!') + ); } // Init kevacoin