Skip to content

Instantly share code, notes, and snippets.

@dcguim
Created January 6, 2016 16:32
Show Gist options
  • Save dcguim/f88d55712b8199906408 to your computer and use it in GitHub Desktop.
Save dcguim/f88d55712b8199906408 to your computer and use it in GitHub Desktop.
(defun call-get-method (url &key parameters)
"Alternative to CALL-REST-METHOD that uses a stream; this is more
memory efficient, but it may cause problems if YASON:PARSE takes
too long to parse the stream and the stream may be cut due to
timeout."
(with-open-stream (s (drakma:http-request url
:parameters parameters
:external-format-out :utf-8
:method :get
:connection-timeout 120
:want-stream t))
(setf (flexi-streams:flexi-stream-external-format s) :utf-8)
(yason:parse s :object-as :hash-table)))
(defun fetch-docs (limit)
(let* ((l (format nil "~a" limit))
(out (call-get-method "http://localhost:8983/solr/wn/select?"
:parameters `(("q" . "-rdf_type:Nominalization")
("wt" . "json")
("rows" . ,l)))))
(gethash "docs" (gethash "response" out))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment