Support elasticsearch 2.0.
authorChristian Weiske <cweiske@cweiske.de>
Tue, 3 Nov 2015 05:16:52 +0000 (06:16 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 3 Nov 2015 06:31:39 +0000 (07:31 +0100)
Requires the delete-by-query plugin for elasticsearch.

README.rst
src/phorkie/Database/Adapter/Elasticsearch/HTTPRequest.php
src/phorkie/Database/Adapter/Elasticsearch/Setup.php

index 6916a357f8453c9a8579c2c764c27a546ea8a078..53293cb13d70127bb678b4841ada62156de6781c 100644 (file)
@@ -155,9 +155,15 @@ phorkie makes use of an Elasticsearch__ installation, if you have one.
 
 It is used to provide search capabilities and the list of recent pastes.
 
 
 It is used to provide search capabilities and the list of recent pastes.
 
-Elasticsearch version 1.3 is supported.
+Elasticsearch version 2.0 is supported.
+
+You have to install the `delete-by-query`__ plugin::
+
+    $ cd /usr/share/elasticsearch
+    $ bin/plugin install delete-by-query
 
 __ http://www.elasticsearch.org/
 
 __ http://www.elasticsearch.org/
+__ https://www.elastic.co/guide/en/elasticsearch/plugins/2.0/plugins-delete-by-query.html
 
 
 Setup
 
 
 Setup
index 24487bcd554d21035154e383f4d369a68987e67b..7c76af25b651f9f3f406b08082fa604d705db441 100644 (file)
@@ -18,7 +18,7 @@ class Database_Adapter_Elasticsearch_HTTPRequest extends \HTTP_Request2
         }
         $js = json_decode($res->getBody());
         if (isset($js->error)) {
         }
         $js = json_decode($res->getBody());
         if (isset($js->error)) {
-            $error = $js->error;
+            $error = json_encode($js->error);
         } else {
             $error = $res->getBody();
         }
         } else {
             $error = $res->getBody();
         }
index bb76d548006976143a1af5ed7ce166ab5bd1c77d..1e632ba1e290bcb0494db966cdc5ede0431c1344 100644 (file)
@@ -33,6 +33,38 @@ class Database_Adapter_Elasticsearch_Setup implements Database_ISetup
         );
         $r->send();
 
         );
         $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();
+
         //create mapping
         //mapping for repositories
         $r = new Database_Adapter_Elasticsearch_HTTPRequest(
         //create mapping
         //mapping for repositories
         $r = new Database_Adapter_Elasticsearch_HTTPRequest(
@@ -45,7 +77,7 @@ class Database_Adapter_Elasticsearch_Setup implements Database_ISetup
                     'repo' => (object)array(
                         '_timestamp' => (object)array(
                             'enabled' => true,
                     'repo' => (object)array(
                         '_timestamp' => (object)array(
                             'enabled' => true,
-                            'path'    => 'tstamp',
+                            //'path'    => 'tstamp',
                         ),
                         'properties' => (object)array(
                             'id' => (object)array(
                         ),
                         'properties' => (object)array(
                             'id' => (object)array(
@@ -73,38 +105,6 @@ class Database_Adapter_Elasticsearch_Setup implements Database_ISetup
             )
         );
         $r->send();
             )
         );
         $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();
     }
 
 }
     }
 
 }