Browse Source

Handle "no results"

Chimo 1 year ago
parent
commit
25cd3e1b13
1 changed files with 13 additions and 9 deletions
  1. 13
    9
      lib/ElasticSearch.php

+ 13
- 9
lib/ElasticSearch.php View File

@@ -237,19 +237,23 @@ class ElasticSearch extends SearchEngine
237 237
         $hits = $response['hits']['hits'];
238 238
 
239 239
         if (count($hits) === 0) {
240
-            return false;
241
-        }
240
+            // No results
241
+            //
242
+            // Force empty result set because if we don't we end up
243
+            // displaying the most recent notices (no WHERE clause)
244
+            $this->target->whereAdd("1 = 2");
245
+        } else {
246
+            $ids = array();
247
+
248
+            foreach($hits as $hit) {
249
+                $ids[] = $hit['_id'];
250
+            }
242 251
 
243
-        $ids = array();
252
+            $id_set = join(', ', $ids);
244 253
 
245
-        foreach($hits as $hit) {
246
-            $ids[] = $hit['_id'];
254
+            $this->target->whereAdd("id in ($id_set)");
247 255
         }
248 256
 
249
-        $id_set = join(', ', $ids);
250
-
251
-        $this->target->whereAdd("id in ($id_set)");
252
-
253 257
         return true;
254 258
     }
255 259
 

Loading…
Cancel
Save