Skip to content

Commit 2a111a0

Browse files
committed
fixed various search and ingest tests
1 parent ecec881 commit 2a111a0

16 files changed

Lines changed: 102 additions & 128 deletions

File tree

access-control-app/src/cmr/access_control/api/routes.clj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@
117117
(defn- create-acl
118118
"Returns a Ring response with the result of trying to create the ACL with the given request body."
119119
[request-ctx headers body]
120-
(println "INSIDE create-acl")
121120
(validate-content-type headers)
122121
(acl-schema/validate-acl-json body)
123122
(try

access-control-app/src/cmr/access_control/services/acl_util.clj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@
7474
(let [acl-concept (merge (acl->base-concept context acl)
7575
{:revision-id 1
7676
:native-id (str (java.util.UUID/randomUUID))})
77-
_ (println "acl-concept = " acl-concept)
7877
resp (mdb/save-concept context acl-concept)]
7978
;; index the saved ACL here to make ingest synchronous
8079
(index/index-acl context

bootstrap-app/src/cmr/bootstrap/data/bulk_index.clj

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
concept-batches (db/find-concepts-in-batches db provider params (:db-batch-size system) start-index)
7878
num-granules (index/bulk-index {:system (helper/get-indexer system)}
7979
concept-batches
80+
cmr.elastic-utils.config/gran-elastic-name
8081
{:target-index-key target-index-key})]
8182
(info "Indexed" num-granules "granule(s) for provider" provider-id "collection" collection-id)
8283
(when completion-message
@@ -98,7 +99,10 @@
9899
params {:concept-type :granule
99100
:provider-id provider-id}
100101
concept-batches (db/find-concepts-in-batches db provider params (:db-batch-size system) start-index)
101-
num-granules (index/bulk-index {:system (helper/get-indexer system)} concept-batches {})]
102+
num-granules (index/bulk-index {:system (helper/get-indexer system)}
103+
concept-batches
104+
cmr.elastic-utils.config/gran-elastic-name
105+
{})]
102106
(info "Indexed" num-granules "granule(s) for provider" provider-id)
103107
num-granules))
104108

@@ -110,7 +114,10 @@
110114
params {:concept-type :collection
111115
:provider-id provider-id}
112116
concept-batches (db/find-concepts-in-batches db provider params (:db-batch-size system))
113-
num-collections (index/bulk-index {:system (helper/get-indexer system)} concept-batches {})]
117+
num-collections (index/bulk-index {:system (helper/get-indexer system)}
118+
concept-batches
119+
cmr.elastic-utils.config/non-gran-elastic-name
120+
{})]
114121
(info "Indexed" num-collections "collection(s) for provider" provider-id)
115122
num-collections))
116123

@@ -128,12 +135,13 @@
128135
gran-count
129136
provider-id)))
130137

138+
;; TODO CMR-10636 fix this. We need to separate out the concepts and go to each seperate cluster
131139
(defn- bulk-index-concept-batches
132140
"Bulk index the given concept batches in both regular index and all revisions index."
133141
[system concept-batches]
134142
(let [indexer-context {:system (helper/get-indexer system)}]
135-
(index/bulk-index indexer-context concept-batches {:all-revisions-index? true})
136-
(index/bulk-index indexer-context concept-batches {})))
143+
(index/bulk-index indexer-context concept-batches nil {:all-revisions-index? true})
144+
(index/bulk-index indexer-context concept-batches nil {})))
137145

138146
(defn- index-concepts-by-provider
139147
"Bulk index concepts for the given provider and concept-type."
@@ -246,12 +254,12 @@
246254
{:concept-type concept-type :concept-id batch}
247255
(:db-batch-size system))]
248256
concept-batch)
249-
total (index/bulk-index {:system (helper/get-indexer system)} concept-batches)]
257+
total (index/bulk-index {:system (helper/get-indexer system)} concept-batches nil)]
250258

251259
;; for concept types that have all revisions index, also index the all revisions index
252260
(when-not (#{:tag :granule} concept-type)
253261
(index/bulk-index
254-
{:system (helper/get-indexer system)} concept-batches {:all-revisions-index? true}))
262+
{:system (helper/get-indexer system)} concept-batches nil {:all-revisions-index? true}))
255263

256264
(info "Indexed " total " concepts.")
257265
total))
@@ -281,7 +289,7 @@
281289
{:concept-type concept-type :concept-id batch}
282290
(:db-batch-size system))]
283291
(map #(assoc % :deleted true) concept-batch))
284-
total (index/bulk-index {:system (helper/get-indexer system)} concept-batches)]
292+
total (index/bulk-index {:system (helper/get-indexer system)} concept-batches nil)]
285293
(info "Deleted " total " concepts")
286294
total))
287295

common-app-lib/src/cmr/common_app/services/search.clj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,12 @@
104104
[result-gen-time result-str] (u/time-execution
105105
(search-results->response
106106
context query (assoc results :took query-execution-time)))]
107-
(println "query-execution-time:" query-execution-time "result-gen-time:" result-gen-time)
107+
(info "query-execution-time:" query-execution-time "result-gen-time:" result-gen-time)
108108
[results result-str]))
109109

110110
(defn find-concepts
111111
"Executes a search for concepts using the given query."
112112
[context _concept-type query]
113-
(println "INSIDE find-concepts in search")
114113
(validate-query context query)
115114
;; If the scroll-id is not nil, first look in the cache to see if there is a deferred result and
116115
;; use that if so. If the scroll-id is not set and scroll is set to 'defer' then store the

elastic-utils-lib/src/cmr/elastic_utils/es_helper.clj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
qp (merge {:track_total_hits true}
1919
(select-keys opts qk))
2020
body (apply dissoc (concat [opts] qk))]
21-
(println "INSIDE final search call to ES with url = " (rest/search-url conn (join-names index)) " and body = " body " with query params = " qp)
2221
(rest/post conn (rest/search-url conn (join-names index))
2322
{:content-type :json
2423
:body body

elastic-utils-lib/src/cmr/elastic_utils/search/es_index.clj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@
171171
cmr.elastic-utils.config/gran-elastic-name
172172
cmr.elastic-utils.config/non-gran-elastic-name))
173173

174-
(defn get-es-cluster-name-by-index-info-type
174+
(defn get-es-cluster-name-by-index-info-type-name
175175
[index-info]
176-
(if (= (:type index-info) "granule")
176+
(if (= (:type-name index-info) "granule")
177177
cmr.elastic-utils.config/gran-elastic-name
178178
cmr.elastic-utils.config/non-gran-elastic-name))
179179

@@ -185,13 +185,13 @@
185185
;(println "INSIDE do-send-with-retry with index info = " index-info " and query = " query)
186186
;; index info = {:index-name , :type-name granule}
187187
;; query = {:search_type query_then_fetch, :size 10, :from 0, :timeout 170s, :version true, :query {:bool {:must {:match_all {}}, :filter {:bool {:must ({:term {:collection-concept-id-doc-values C1200000001-JM_PROV1}} {:term {:concept-id G1200000002-JM_PROV1}})}}}}, :_source (:concept-id :revision-id :native-id-stored :provider-id-doc-values :metadata-format :revision-date-stored-doc-values :collection-concept-id-doc-values), :sort ({:provider-id-lowercase-doc-values {:order :asc}} {:start-date-doc-values {:order :asc}} {:concept-seq-id-long {:order asc}})}
188-
(println "10636- INSIDE do-send-with-retry with index-info = " index-info ". Determined the es cluster is = " (get-es-cluster-name-by-index-info-type index-info))
188+
(println "10636- INSIDE do-send-with-retry with index-info = " index-info ". Determined the es cluster is = " (get-es-cluster-name-by-index-info-type-name index-info))
189189
(try
190190
(if (pos? max-retries)
191191
(if-let [scroll-id (:scroll-id query)]
192192
(scroll-search context scroll-id)
193193
(es-helper/search
194-
(context->conn context (get-es-cluster-name-by-index-info-type index-info))
194+
(context->conn context (get-es-cluster-name-by-index-info-type-name index-info))
195195
(:index-name index-info)
196196
[(:type-name index-info)]
197197
query))

elastic-utils-lib/src/cmr/elastic_utils/search/query_execution.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
elastic-results (->> processed-query
104104
(#(if (or (tc/echo-system-token? context) (:skip-acls? %))
105105
%
106-
(add-acl-conditions-to-query context %))) ;; TODO CMR-10636 - is this going to be an issue?
106+
(add-acl-conditions-to-query context %)))
107107
(c2s/reduce-query context)
108108
(idx/execute-query context))
109109
query-results (rc/elastic-results->query-results context processed-query elastic-results)]

indexer-app/src/cmr/indexer/data/collection_granule_aggregation_cache.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@
229229
(meta-db/get-latest-concepts context)
230230
;; wrap it in a vector to make a batch to bulk index
231231
vector
232-
(index-service/bulk-index context)))))
232+
(index-service/bulk-index context cmr.elastic-utils.config/non-gran-elastic-name)))))
233233

234234
;; There's no existing value so a full refresh is required.
235235
(full-cache-refresh context))))

indexer-app/src/cmr/indexer/data/elasticsearch.clj

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -360,31 +360,29 @@
360360
{:keys [_id status error]} resp-data]]
361361
(log/error (format "[%s] failed bulk indexing with status [%d] and error [%s]" _id status error)))))
362362

363-
;; TODO 10636- have to separate the docs in the bulk to non-gran and gran -- going to just disable this for now
363+
;; TODO 10636- check validity of this
364364
(defn bulk-index-autocomplete-suggestions
365365
"Save a batch of suggestion documents in Elasticsearch."
366366
[context docs]
367-
;(doseq [docs-batch (partition-all MAX_BULK_OPERATIONS_PER_REQUEST docs)]
368-
; (let [bulk-operations (cmr-bulk/create-bulk-index-operations docs-batch)
369-
; conn (indexer-util/context->conn context)
370-
; response (es-helper/bulk conn bulk-operations)]
371-
; (handle-bulk-index-response response)))
367+
(doseq [docs-batch (partition-all MAX_BULK_OPERATIONS_PER_REQUEST docs)]
368+
(let [bulk-operations (cmr-bulk/create-bulk-index-operations docs-batch)
369+
conn (indexer-util/context->conn context cmr.elastic-utils.config/non-gran-elastic-name)
370+
response (es-helper/bulk conn bulk-operations)]
371+
(handle-bulk-index-response response)))
372372
nil
373373
)
374374

375-
;; TODO 10636- have to separate the docs in the bulk to non-gran and gran -- going to just disable this for now
375+
;; TODO 10636- check validity of this
376376
(defn bulk-index-documents
377377
"Save a batch of documents in Elasticsearch."
378-
([context docs]
379-
(bulk-index-documents context docs nil))
380-
([context docs {:keys [all-revisions-index?]}]
381-
;(doseq [docs-batch (partition-all MAX_BULK_OPERATIONS_PER_REQUEST docs)]
382-
; (let [bulk-operations (cmr-bulk/create-bulk-index-operations docs-batch all-revisions-index?)
383-
; conn (indexer-util/context->conn context)
384-
; response (es-helper/bulk conn bulk-operations)]
385-
; (handle-bulk-index-response response)))
386-
nil
387-
))
378+
([context docs es-cluster-name]
379+
(bulk-index-documents context docs es-cluster-name nil))
380+
([context docs es-cluster-name {:keys [all-revisions-index?]}]
381+
(doseq [docs-batch (partition-all MAX_BULK_OPERATIONS_PER_REQUEST docs)]
382+
(let [bulk-operations (cmr-bulk/create-bulk-index-operations docs-batch all-revisions-index?)
383+
conn (indexer-util/context->conn context es-cluster-name)
384+
response (es-helper/bulk conn bulk-operations)]
385+
(handle-bulk-index-response response)))))
388386

389387
(defn get-es-cluster-conn
390388
[context es-index]

indexer-app/src/cmr/indexer/services/index_service.clj

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@
139139
* :all-revisions-index? - true indicates this should be indexed into the all revisions index
140140
* :force-version? - true indicates that we should overwrite whatever is in elasticsearch with the
141141
latest regardless of whether the version in the database is older than the _version in elastic."
142-
([context concept-batches]
143-
(bulk-index context concept-batches nil))
144-
([context concept-batches options]
142+
([context concept-batches es-cluster-name]
143+
(bulk-index context concept-batches es-cluster-name nil))
144+
([context concept-batches es-cluster-name options]
145145
(reduce (fn [num-indexed batch]
146146
(let [batch (prepare-batch context batch options)]
147-
(es/bulk-index-documents context batch options)
147+
(es/bulk-index-documents context batch es-cluster-name options)
148148
(+ num-indexed (count batch))))
149149
0
150150
concept-batches)))
@@ -260,8 +260,11 @@
260260
:collection
261261
(determine-reindex-batch-size provider-id)
262262
{:provider-id provider-id :latest true})]
263-
(bulk-index context latest-collection-batches {:all-revisions-index? false
264-
:force-version? force-version?})))
263+
(println "latest-collection-batches = " latest-collection-batches)
264+
(bulk-index context
265+
latest-collection-batches
266+
cmr.elastic-utils.config/non-gran-elastic-name
267+
{:all-revisions-index? false :force-version? force-version?})))
265268

266269
(when (or (nil? all-revisions-index?) all-revisions-index?)
267270
;; Note that this will not unindex revisions that were removed directly from the database.
@@ -272,8 +275,10 @@
272275
:collection
273276
(determine-reindex-batch-size provider-id)
274277
{:provider-id provider-id})]
275-
(bulk-index context all-revisions-batches {:all-revisions-index? true
276-
:force-version? force-version?}))))))
278+
(bulk-index context
279+
all-revisions-batches
280+
cmr.elastic-utils.config/non-gran-elastic-name
281+
{:all-revisions-index? true :force-version? force-version?}))))))
277282

278283
(defconfig non-collection-reindex-batch-size
279284
"Batch size used for re-indexing other things besides collections."
@@ -289,7 +294,7 @@
289294
:tag
290295
(non-collection-reindex-batch-size)
291296
{:latest true})]
292-
(bulk-index context latest-tag-batches)))
297+
(bulk-index context latest-tag-batches cmr.elastic-utils.config/non-gran-elastic-name)))
293298

294299
(defn- time-to-visibility-text
295300
"This is the original log entry used by Splunk to report on time to index.

0 commit comments

Comments
 (0)