$db = new Database();
$idx = $db->getIndexer();
-//cleanup
-echo "Deleting all index data\n";
-$idx->deleteAllRepos();
-
//create mapping
-echo "Index setup\n";
-$db->getSetup()->setup();
+echo "Index reset\n";
+$db->getSetup()->reset();
$rs = new Repositories();
public function setup()
{
- $r = new Database_Adapter_Elasticsearch_HTTPRequest(
- $this->searchInstance . 'repo/_mapping',
+ $r = new \HTTP_Request2(
+ $this->searchInstance . '/_mapping', \HTTP_Request2::METHOD_GET
+ );
+ $res = $r->send();
+ if ($res->getStatus() == 404) {
+ $this->reset();
+ }
+ }
+
+ public function reset()
+ {
+ $r = new \HTTP_Request2(
+ $this->searchInstance,
\HTTP_Request2::METHOD_DELETE
);
$r->send();
+ $r = new Database_Adapter_Elasticsearch_HTTPRequest(
+ $this->searchInstance,
+ \HTTP_Request2::METHOD_PUT
+ );
+ $r->send();
+
//create mapping
//mapping for repositories
$r = new Database_Adapter_Elasticsearch_HTTPRequest(
public function checkDatabase()
{
- $dbs = new Database_Setup_Elasticsearch();
- $dbs->setup();
+ $dbs = new Database();
+ $dbs->getSetup()->setup();
}
public function fail($msg)