@ -1,6 +1,7 @@
( defpackage #:search
( defpackage #:search
( :use #:cl
( :use #:cl
#:app-constants
#:app-constants
#:archive
#:cl-json
#:cl-json
#:local-time
#:local-time
#:utils )
#:utils )
@ -16,7 +17,9 @@
#:set-filter-attributes
#:set-filter-attributes
#:delete-all-entries
#:delete-all-entries
#:create-dump
#:create-dump
#:update-ranking-rules ) )
#:update-ranking-rules
#:repopulate-database
#:delete-index ) )
( in-package #:search )
( in-package #:search )
;; Explains the "~{~A~^,~}" in the format call below.
;; Explains the "~{~A~^,~}" in the format call below.
@ -41,7 +44,6 @@ Note: The JSON object to encoded as a string."
( "thumbnail-path" . , thumbnail-path-value )
( "thumbnail-path" . , thumbnail-path-value )
( "year" . , publish-year-value )
( "year" . , publish-year-value )
( "month" . , publish-month-value )
( "month" . , publish-month-value )
;; ("day" . ,(local-time:timestamp-day created-at-value))
( "keywords" . , ( cl-ppcre:split "," keywords-value ) ) ) ) ) )
( "keywords" . , ( cl-ppcre:split "," keywords-value ) ) ) ) ) )
( defun build-search-url ( path )
( defun build-search-url ( path )
@ -52,6 +54,7 @@ site is running in and use the beta or prod. URL's to connect to meilisearch.
the base URL. "
the base URL. "
( if ( ritherdon-archive.config:developmentp )
( if ( ritherdon-archive.config:developmentp )
( concatenate 'string "http://localhost:7700" path )
( concatenate 'string "http://localhost:7700" path )
( utils:build-url-root )
( concatenate 'string "https://www.nera.com" path ) ) )
( concatenate 'string "https://www.nera.com" path ) ) )
( defun delete-entry ( id )
( defun delete-entry ( id )
@ -145,3 +148,33 @@ database first (when no search term is entered by the user)."
( utils:run-bash-command
( 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\" ]\'"
( 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 ) ) ) )
( build-search-url "/indexes/nera/settings" ) ( meilisearch-api-key ) ) ) )
( defun repopulate-database ( archive-entries )
"Empties the Meilisearch database and populates it with `ARCHIVE-ENTRIES'."
( delete-all-entries )
( loop for entry in archive-entries
do
( submit-entry
( build-payload ( archive::search-id-of entry )
( archive::title-of entry )
( format nil "view/archive/~a"
( archive::slug-of entry ) )
( format nil "storage/thumb/archive/~a"
( archive::slug-of entry ) )
( archive::month-of entry )
( archive::year-of entry )
( archive::keywords-of entry ) ) ) ) )
( defun delete-index ( index-name )
" Deletes ` INDEX-NAME ' in Meilisearch DB, doesn 't need to be this project.
Because Meilisearch is a seperate service running alongside this website, it can
host searchable databases for other projects on the system. ` INDEX-NAME ' refers
to those other databases.
I have not hard-coded this project 's database name into this function out of
convenience. I can call this function from SLIME/SLY and clean-up my Meilisearch
dev. instance. It, also, helps if I 've made botched this project 's DB with an
incorrect name and need to quickly delete it. "
( utils:run-bash-command
( format nil "curl -X DELETE \'~a\'"
( build-search-url ( format nil "/indexes/~a" index-name ) ) ) ) )