;; search prefix / wildcard queries — Haskell source fragment. Depends on index +
;; rank (reuses candStep / rankTfIdf). A prefix matches every indexed term that
;; starts with it; the matching terms are unioned (OR) into a docid set.
;;   prefixTerms     :: String -> Index -> [Term]      (sorted, from allTerms)
;;   prefixDocs      :: String -> Index -> [DocId]     (sorted union)
;;   prefixRankTfIdf :: String -> Index -> [DocId]     (ranked by the matched terms)

(define
  search/prefix-src
  "prefixTerms pre idx = filter (isPrefixOf pre) (allTerms idx)\nprefixDocs pre idx = foldl (candStep idx) [] (prefixTerms pre idx)\nprefixRankTfIdf pre idx = rankTfIdf (prefixTerms pre idx) idx\n")
