From 2d862e29e26abb9af52ed13ddc098ab4ad1e65a3 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Mon, 17 Oct 2022 20:39:45 +0100 Subject: [PATCH] add 'update'ranking-rules' func. to search package. This allows you to change the order the search results are returned in. The main purpose why you would want to use this function in this context is to make sure the list of results is ordered by the year the artworks where published/created. --- src/search.lisp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/search.lisp b/src/search.lisp index c41871e..7e348ab 100644 --- a/src/search.lisp +++ b/src/search.lisp @@ -15,7 +15,8 @@ #:submit-entry #:set-filter-attributes #:delete-all-entries - #:create-dump)) + #:create-dump + #:update-ranking-rules)) (in-package #:search) ;; Explains the "~{~A~^,~}" in the format call below. @@ -136,3 +137,11 @@ has requested. She would like the filtering to consist on years and months." "Creates a dump of the Meilisearch database." (utils:run-bash-command (format nil "curl -X POST \'~a\'" (build-search-url "/dumps")))) + +(defun update-ranking-rules () + "Updates the way Meilisearch ranks and orders the search results. +The main intention for this function is to show the latest entries into the +database first (when no search term is entered by the user)." + (utils:run-bash-command + (format nil "curl -X PATCH \'~a\' -H \'Authorization: ~a\' -H \'Content-Type: application/json\' --data-binary \'[ \"words\", \"typo\", \"proximity\", \"attribute\", \"sort\", \"exactness\",\"rank:asc\", \"year:desc\" ]\'" + (build-search-url "/indexes/nera/settings") (meilisearch-api-key))))