From 6e4da8dc261c471cf41f3250af9cb6213fe8703d Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Mon, 10 Oct 2022 17:08:53 +0100 Subject: [PATCH] implement set-filter-attributes, delete-all-entries and create-dump. These functions are helper functions to manage the Meiliseach database from a Common Lisp perspective. The intention is to work them into the website's back-end so the user can reset or re-populate the database from the website without me (or someone else) having to SSH into the VM and do fix/restore things manually. For now, they allow you to manage the database from SLIME. --- src/search.lisp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/search.lisp b/src/search.lisp index 51a8d21..e4dc2e3 100644 --- a/src/search.lisp +++ b/src/search.lisp @@ -13,7 +13,9 @@ #:get-id #:get-keywords #:submit-entry - #:set-filter-attributes)) + #:set-filter-attributes + #:delete-all-entries + #:create-dump)) (in-package #:search) ;; Explains the "~{~A~^,~}" in the format call below. @@ -124,3 +126,14 @@ has requested. She would like the filtering to consist on years and months." (utils:run-bash-command (format nil "curl -X PATCH \'~a\' -H \'Authorization: ~a\' -H \'Content-Type: application/json\' --data-binary \'{ \"filterableAttributes\": [ \"year\", \"month\", \"keywords\" ]}\'" (build-search-url "/indexes/nera/settings") (meilisearch-api-key)))) + +(defun delete-all-entries () + "Deletes all the archive entries in the Meilisearch database -- not the DB." + (utils:run-bash-command + (format nil "curl -X DELETE \'~a\'" + (build-search-url "/indexes/nera/documents")))) + +(defun create-dump () + "Creates a dump of the Meilisearch database." + (utils:run-bash-command + (format nil "curl -X POST \'~a\'" (build-search-url "/dumps"))))