makes cloud search possible.

This commit is contained in:
2023-05-04 17:07:08 -07:00
parent 2bb1da1636
commit b200728c6a
30 changed files with 1308 additions and 451 deletions

32
src/clj/auto_ap/solr.clj Normal file
View 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" "*:*"}})})
)