Browse Source

Update README

Chimo 1 year ago
parent
commit
79e3358943
2 changed files with 15 additions and 23 deletions
  1. 12
    21
      ElasticSearchPlugin.php
  2. 3
    2
      README.md

+ 12
- 21
ElasticSearchPlugin.php View File

@@ -12,17 +12,15 @@ class ElasticSearchPlugin extends Plugin
12 12
 
13 13
     function onGetSearchEngine(Memcached_DataObject $target, $table, &$search_engine)
14 14
     {
15
-        if ($this->isEnabled()) {
16
-            $engine = $this->createEngine($target);
15
+        $engine = $this->createEngine($target);
17 16
 
18
-            // TODO: Error handling
17
+        // TODO: Error handling
18
+        //       Consider falling back to built-in search on error
19
+        //       (i.e.: returning `true`)
19 20
 
20
-            $search_engine = $engine;
21
+        $search_engine = $engine;
21 22
 
22
-            return false;
23
-        }
24
-
25
-        return true;
23
+        return false;
26 24
     }
27 25
 
28 26
     function onEndNoticeSaveWeb($action, $notice)
@@ -41,14 +39,12 @@ class ElasticSearchPlugin extends Plugin
41 39
 
42 40
     function handleNoticeSave($notice)
43 41
     {
44
-        if ($this->isEnabled()) {
45
-            $engine = $this->createEngine(new Notice());
46
-
47
-            if ($notice->getVerb(true) === 'delete') {
48
-                $engine->delete($notice);
49
-            } else {
50
-                $engine->index($notice);
51
-            }
42
+        $engine = $this->createEngine(new Notice());
43
+
44
+        if ($notice->getVerb(true) === 'delete') {
45
+            $engine->delete($notice);
46
+        } else {
47
+            $engine->index($notice);
52 48
         }
53 49
     }
54 50
 
@@ -75,11 +71,6 @@ class ElasticSearchPlugin extends Plugin
75 71
         return $index_name;
76 72
     }
77 73
 
78
-    function isEnabled()
79
-    {
80
-        return common_config('elasticsearch', 'enabled');
81
-    }
82
-
83 74
     function onPluginVersion(array &$versions)
84 75
     {
85 76
         $versions[] = array('name' => 'Elasticsearch backend',

+ 3
- 2
README.md View File

@@ -11,7 +11,6 @@
11 11
 Tell `/config.php` to use it with (replace `127.0.0.1:9200` with the address/port of your elasticsearch backend server):
12 12
 
13 13
 ```
14
-    $config['elasticsearch']['enabled'] = true;
15 14
     $config['elasticsearch']['hosts'] = [ '127.0.0.1:9200' ];
16 15
     $config['elasticsearch']['index_name'] = 'gnusocial';
17 16
     addPlugin('ElasticSearch');
@@ -26,7 +25,9 @@ You can use the [Lucene query syntax](https://www.elastic.co/guide/en/elasticsea
26 25
 Supported fields:
27 26
 
28 27
 * text: Filters by notice text (default field)
29
-* author: Filters by notice username
28
+* author: Notice author (in webfinger format: username@example.org)
29
+* type: Notice type (ex: post, share, like, etc)
30
+* created: Date the notice was created
30 31
 
31 32
 The `/search/notice` page searches notice text by default. You can filter by notice author with the `author` field parameter.
32 33
 

Loading…
Cancel
Save