diff options
author | Arun Isaac | 2022-06-29 00:29:28 +0530 |
---|---|---|
committer | Arun Isaac | 2022-06-29 00:31:21 +0530 |
commit | 3655b4ca24ff71a55ba119f30abba149e93cb43d (patch) | |
tree | 6335fbc170d8d9280764ff7654a0a7c6c9191574 | |
parent | a8023a99111233fec4b6050c6de3130097e84483 (diff) | |
download | tissue-3655b4ca24ff71a55ba119f30abba149e93cb43d.tar.gz tissue-3655b4ca24ff71a55ba119f30abba149e93cb43d.tar.lz tissue-3655b4ca24ff71a55ba119f30abba149e93cb43d.zip |
search: Accept search query as a single string.
* tissue/search.scm (search-fold, search-map): Accept search query as
a single string instead of a list of strings.
* bin/tissue (tissue-search): Pass a single search string to
search-fold.
* tissue/web/server.scm (handler): Pass a single search string to
search-map.
-rwxr-xr-x | bin/tissue | 2 | ||||
-rw-r--r-- | tissue/search.scm | 29 | ||||
-rw-r--r-- | tissue/web/server.scm | 2 |
3 files changed, 14 insertions, 19 deletions
@@ -90,7 +90,7 @@ Search issues using SEARCH-QUERY. (search-fold (lambda (document mset count) (print document mset) (1+ count)) - 0 db args))))))) + 0 db (string-join args)))))))) (define tissue-show (match-lambda* diff --git a/tissue/search.scm b/tissue/search.scm index 647ae5b..ede23aa 100644 --- a/tissue/search.scm +++ b/tissue/search.scm @@ -25,10 +25,9 @@ #:export (search-fold search-map)) -(define (search-fold proc initial db search-terms) - "Search xapian database DB using SEARCH-TERMS and fold over the -results using PROC and INITIAL. SEARCH-TERMS is a list of search terms -that are joined with the \"AND\" operator. +(define (search-fold proc initial db search-query) + "Search xapian database DB using SEARCH-QUERY and fold over the +results using PROC and INITIAL. PROC is invoked as (PROC DOCUMENT MSET PREVIOUS). DOCUMENT is an instance of <document> or one of its subclasses. MSET is the xapian @@ -40,15 +39,12 @@ first call." ;; assume is:open. Assuming is:open is ;; implicitly assuming type:issue since only ;; issues can have is:open. - (if (every string-null? search-terms) + (if (string-null? search-query) "is:open" - (string-join (if (any (lambda (query-string) - (or (string-contains-ci query-string "type:") - (string-contains-ci query-string "is:"))) - search-terms) - search-terms - (cons "is:open" search-terms)) - " AND ")) + (if (or (string-contains-ci search-query "type:") + (string-contains-ci search-query "is:")) + search-query + (string-append "is:open " search-query))) #:stemmer (make-stem "en") #:prefixes '(("type" . "XT") ("title" . "S") @@ -67,10 +63,9 @@ first call." (enquire-mset (enquire db query) #:maximum-items (database-document-count db))))) -(define (search-map proc db search-terms) - "Search xapian database DB using SEARCH-TERMS and map over the results -using PROC. SEARCH-TERMS are a list of search terms that are joined -with the \"AND\" operator. +(define (search-map proc db search-query) + "Search xapian database DB using SEARCH-QUERY and map over the results +using PROC. PROC is invoked as (PROC DOCUMENT MSET). DOCUMENT is an instance of <document> or one of its subclasses. MSET is the xapian MSet object @@ -81,4 +76,4 @@ representing the search results." result)) '() db - search-terms))) + search-query))) diff --git a/tissue/web/server.scm b/tissue/web/server.scm index c2b59e1..1a91810 100644 --- a/tissue/web/server.scm +++ b/tissue/web/server.scm @@ -143,7 +143,7 @@ to a stylesheet." (lambda (db) (search-map document->sxml db - (list (assoc-ref parameters "query"))))) + (assoc-ref parameters "query")))) css)))) (else (values (build-response #:code 404) |