summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2020-03-05 19:43:21 +0530
committerArun Isaac2020-03-05 19:47:38 +0530
commitede26b808188eb4d14c6b4181c933dfc09c0a22e (patch)
tree9e187d20de6b3edf6c5d11f9a1ab0e9464629dbf
parentb10b6b76d375fea021a7e93e51c5243fcef99370 (diff)
downloadguile-xapian-ede26b808188eb4d14c6b4181c933dfc09c0a22e.tar.gz
guile-xapian-ede26b808188eb4d14c6b4181c933dfc09c0a22e.tar.lz
guile-xapian-ede26b808188eb4d14c6b4181c933dfc09c0a22e.zip
xapian: Wrap Enquire-get-mset using keyword arguments.
* xapian/xapian.scm (enquire-mset): Introduce offset and maximum-items keyword arguments. * examples/search.scm (search): Pass pagesize as keyword argument to enquire-mset. Remove argument offset.
-rw-r--r--examples/search.scm5
-rw-r--r--xapian/xapian.scm12
2 files changed, 14 insertions, 3 deletions
diff --git a/examples/search.scm b/examples/search.scm
index fee945e..e8f8aa5 100644
--- a/examples/search.scm
+++ b/examples/search.scm
@@ -25,7 +25,7 @@
(match record
((description title identifier) title)))
-(define* (search dbpath querystring #:key (offset 0) (pagesize 10))
+(define* (search dbpath querystring #:key (pagesize 10))
;; Open database for reading. call-with-database automatically
;; closes the database once we're done.
(call-with-database dbpath
@@ -49,7 +49,8 @@
;; Get an Enquire object from the database with the
;; search results. Then, extract the MSet from the
;; Enquire object.
- (enquire-mset (enquire db query) offset pagesize))))))
+ (enquire-mset (enquire db query)
+ #:maximum-items pagesize))))))
;; Handle command line arguments
(match (command-line)
diff --git a/xapian/xapian.scm b/xapian/xapian.scm
index 181a3e8..2ddc8b4 100644
--- a/xapian/xapian.scm
+++ b/xapian/xapian.scm
@@ -110,7 +110,17 @@
(Enquire-set-weighting-scheme enquire weighting-scheme))
enquire))
-(define enquire-mset Enquire-get-mset)
+(define* (enquire-mset enquire #:key (offset 0) maximum-items)
+ "Run a query using the settings in the ENQUIRE object and return an
+mset object.
+
+OFFSET specifies the number of items to ignore at the beginning of the
+result set.
+
+MAXIMUM-ITEMS specifies the maximum number of items to return. To
+return all matches, pass the result of calling database-document-count
+on the database object."
+ (Enquire-get-mset enquire offset maximum-items))
(define mset-item-docid MSetIterator-get-docid)
(define mset-item-document MSetIterator-get-document)