makes cloud search possible.
This commit is contained in:
32
src/clj/auto_ap/solr.clj
Normal file
32
src/clj/auto_ap/solr.clj
Normal file
@@ -0,0 +1,32 @@
|
||||
(ns auto-ap.solr
|
||||
(:require [clojure.data.json :as json]
|
||||
[clj-http.client :as client]
|
||||
[config.core :refer [env]]))
|
||||
|
||||
(def solr-uri (:solr-uri env))
|
||||
|
||||
(defn index-documents [xs]
|
||||
(client/post
|
||||
(str solr-uri "/solr/invoices/update?commitWithin=15000")
|
||||
{:headers {"Content-Type" "application/json"}
|
||||
:method "POST"
|
||||
:body (json/write-str xs)}))
|
||||
|
||||
(defn query [q]
|
||||
(-> (client/post (str solr-uri "/solr/invoices/query")
|
||||
{:body (json/write-str {"query" q
|
||||
"fields" "id, date, amount, type, description, number, client_code, client_id, vendor_name"})
|
||||
:headers {"Content-Type" "application/json"}
|
||||
:as :json}
|
||||
)
|
||||
:body
|
||||
:response
|
||||
:docs))
|
||||
|
||||
(defn solr-delete []
|
||||
(client/post
|
||||
(str solr-uri "/solr/invoices/update?commitWithin=1000")
|
||||
{:headers {"Content-Type" "application/json"}
|
||||
:method "POST"
|
||||
:body (json/write-str {"delete" {"query" "*:*"}})})
|
||||
)
|
||||
Reference in New Issue
Block a user