(cloud) adjustments for ezcater tenders, search fixes.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
(ns auto-ap.solr
|
||||
(:require
|
||||
[auto-ap.datomic :refer [conn pull-id]]
|
||||
[cemerick.url :as url]
|
||||
[auto-ap.time :as atime]
|
||||
[clj-http.client :as client]
|
||||
[clj-time.coerce :as c]
|
||||
@@ -118,26 +119,38 @@
|
||||
|
||||
|
||||
(defprotocol SolrClient
|
||||
(index-documents [this xs])
|
||||
(query [this q])
|
||||
(delete [this]))
|
||||
(index-documents-raw [this index xs])
|
||||
(index-documents [this index xs])
|
||||
(query [this index q])
|
||||
(delete [this index]))
|
||||
|
||||
(defrecord RealSolrClient [solr-uri]
|
||||
|
||||
SolrClient
|
||||
(index-documents [this xs]
|
||||
(index-documents-raw [this index xs]
|
||||
(client/post
|
||||
(str solr-uri "/solr/invoices/update?commitWithin=15000")
|
||||
(str (assoc (url/url solr-uri "solr" index "update")
|
||||
:query {"commitWithin" 60000}))
|
||||
|
||||
{:headers {"Content-Type" "application/json"}
|
||||
:socket-timeout 30000
|
||||
:connection-timeout 30000
|
||||
:method "POST"
|
||||
:body (json/write-str xs)}))
|
||||
|
||||
(index-documents [this index xs]
|
||||
(client/post
|
||||
(str (assoc (url/url solr-uri "solr" index "update")
|
||||
:query {"commitWithin" 60000}))
|
||||
{:headers {"Content-Type" "application/json"}
|
||||
:socket-timeout 30000
|
||||
:connection-timeout 30000
|
||||
:method "POST"
|
||||
:body (json/write-str (filter identity (map datomic->solr xs)))}))
|
||||
|
||||
(query [this 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"})
|
||||
(query [this index q]
|
||||
(-> (client/post (str (url/url solr-uri "solr" index "query"))
|
||||
{:body (json/write-str q )
|
||||
:socket-timeout 30000
|
||||
:connection-timeout 30000
|
||||
:headers {"Content-Type" "application/json"}
|
||||
@@ -146,21 +159,25 @@
|
||||
:body
|
||||
:response
|
||||
:docs))
|
||||
(delete [this]
|
||||
(delete [this index]
|
||||
(client/post
|
||||
(str solr-uri "/solr/invoices/update?commitWithin=1000")
|
||||
(str (assoc (url/url solr-uri "solr" index "update")
|
||||
:query {"commitWithin" 15000}))
|
||||
{:headers {"Content-Type" "application/json"}
|
||||
:method "POST"
|
||||
:body (json/write-str {"delete" {"query" "*:*"}})})))
|
||||
|
||||
(defrecord MockSolrClient []
|
||||
SolrClient
|
||||
(index-documents [this xs]
|
||||
(index-documents [this index xs]
|
||||
nil)
|
||||
|
||||
(query [this q]
|
||||
(index-documents-raw [this index xs]
|
||||
nil)
|
||||
(delete [this]
|
||||
|
||||
(query [this index q]
|
||||
nil)
|
||||
(delete [this index]
|
||||
nil))
|
||||
|
||||
(def impl (if (= :solr (:solr-impl env))
|
||||
@@ -172,9 +189,11 @@
|
||||
|
||||
|
||||
(defn touch-with-ledger [i]
|
||||
(index-documents impl [i [:journal-entry/original-entity i]]))
|
||||
(index-documents impl "invoices" [i [:journal-entry/original-entity i]]))
|
||||
|
||||
(defn touch [i]
|
||||
(index-documents impl [i]))
|
||||
(defn touch
|
||||
([i] (touch i "invoices"))
|
||||
([i index]
|
||||
(index-documents impl index [i])))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user