diff options
author | Bob131 | 2021-09-02 07:48:38 +1000 |
---|---|---|
committer | Arun Isaac | 2021-09-07 01:23:59 +0530 |
commit | 110bca15a7d89955805589cd3451ab52f9a52748 (patch) | |
tree | db91f272c25036358dc7c75b5d0a799b1fc55b75 | |
parent | ec334fae367af039b83b824e29460b059b0c12af (diff) | |
download | guile-xapian-110bca15a7d89955805589cd3451ab52f9a52748.tar.gz guile-xapian-110bca15a7d89955805589cd3451ab52f9a52748.tar.lz guile-xapian-110bca15a7d89955805589cd3451ab52f9a52748.zip |
xapian: make-document: Accept bytevectors.
* xapian/xapian.scm (make-document): Support setting document values
and body from bytevectors.
Signed-off-by: Arun Isaac <arunisaac@systemreboot.net>
-rw-r--r-- | xapian/xapian.scm | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/xapian/xapian.scm b/xapian/xapian.scm index bd613a7..171203d 100644 --- a/xapian/xapian.scm +++ b/xapian/xapian.scm @@ -82,14 +82,21 @@ in-memory database would always remain empty and is of little use." (define* (make-document #:key data (terms '()) (values '())) (let ((doc (new-Document))) (when data - (Document-set-data doc data)) + (cond + ((string? data) + (Document-set-data doc data)) + ((bytevector? data) + (Document-set-data-bytes doc data)) + (else (error "Invalid document data" data)))) (for-each (match-lambda ((term . wdf-increment) (Document-add-term doc term wdf-increment))) terms) (for-each (match-lambda - ((slot . value) - (Document-add-value doc slot value))) + ((slot . (? string? value)) + (Document-add-value doc slot value)) + ((slot . (? bytevector? value)) + (Document-add-value-bytes doc slot value))) values) doc)) |