From 7c5ea8dded583601f29c7ea9bcb507ecbdd854d6 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Mon, 7 May 2012 20:47:01 +0200 Subject: move elasticsearch code in one folder --- .../Database/Adapter/Elasticsearch/Setup.php | 91 ++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 src/phorkie/Database/Adapter/Elasticsearch/Setup.php (limited to 'src/phorkie/Database/Adapter/Elasticsearch/Setup.php') diff --git a/src/phorkie/Database/Adapter/Elasticsearch/Setup.php b/src/phorkie/Database/Adapter/Elasticsearch/Setup.php new file mode 100644 index 0000000..acbe77c --- /dev/null +++ b/src/phorkie/Database/Adapter/Elasticsearch/Setup.php @@ -0,0 +1,91 @@ +searchInstance = $GLOBALS['phorkie']['cfg']['elasticsearch']; + } + + public function setup() + { + $r = new Database_Adapter_Elasticsearch_HTTPRequest( + $this->searchInstance . 'repo/_mapping', + \HTTP_Request2::METHOD_DELETE + ); + $r->send(); + + //create mapping + //mapping for repositories + $r = new Database_Adapter_Elasticsearch_HTTPRequest( + $this->searchInstance . 'repo/_mapping', + \HTTP_Request2::METHOD_PUT + ); + $r->setBody( + json_encode( + (object)array( + 'repo' => (object)array( + '_timestamp' => (object)array( + 'enabled' => true, + 'path' => 'tstamp', + ), + 'properties' => (object)array( + 'id' => (object)array( + 'type' => 'long' + ), + 'description' => (object)array( + 'type' => 'string', + 'boost' => 2.0 + ), + 'crdate' => (object)array( + //creation date + 'type' => 'date', + ), + 'tstamp' => (object)array( + //modification date + 'type' => 'date', + ) + ) + ) + ) + ) + ); + $r->send(); + + //mapping for files + $r = new Database_Adapter_Elasticsearch_HTTPRequest( + $this->searchInstance . 'file/_mapping', + \HTTP_Request2::METHOD_PUT + ); + $r->setBody( + json_encode( + (object)array( + 'file' => (object)array( + '_parent' => (object)array( + 'type' => 'repo' + ), + 'properties' => (object)array( + 'name' => (object)array( + 'type' => 'string', + 'boost' => 1.5 + ), + 'extension' => (object)array( + 'type' => 'string', + 'boost' => 1.0 + ), + 'content' => (object)array( + 'type' => 'string', + 'boost' => 0.8 + ) + ) + ) + ) + ) + ); + $r->send(); + } + +} + +?> -- cgit v1.2.3