|
8 | 8 | [cmr.common.concepts :as cc] |
9 | 9 | [cmr.common.log :refer (info warn error)] |
10 | 10 | [cmr.common.util :as util] |
| 11 | + [cmr.elastic-utils.config :as es-config] |
11 | 12 | [cmr.elastic-utils.es-helper :as es-helper] |
12 | 13 | [cmr.indexer.indexer-util :as indexer-util] |
13 | 14 | [cmr.indexer.data.elasticsearch :as es] |
|
138 | 139 | ;; TODO CMR-10636 fix this. We need to separate out the concepts and go to each seperate cluster |
139 | 140 | (defn- bulk-index-concept-batches |
140 | 141 | "Bulk index the given concept batches in both regular index and all revisions index." |
141 | | - [system concept-batches] |
| 142 | + [system concept-batches es-cluster-name] |
142 | 143 | (let [indexer-context {:system (helper/get-indexer system)}] |
143 | | - (index/bulk-index indexer-context concept-batches nil {:all-revisions-index? true}) |
144 | | - (index/bulk-index indexer-context concept-batches nil {}))) |
| 144 | + (index/bulk-index indexer-context concept-batches es-cluster-name {:all-revisions-index? true}) |
| 145 | + (index/bulk-index indexer-context concept-batches es-cluster-name {}))) |
145 | 146 |
|
146 | 147 | (defn- index-concepts-by-provider |
147 | 148 | "Bulk index concepts for the given provider and concept-type." |
|
158 | 159 | db provider |
159 | 160 | params |
160 | 161 | (:db-batch-size system)) |
161 | | - num-concepts (bulk-index-concept-batches system concept-batches) |
| 162 | + es-cluster-name (if (= concept-type :granule) |
| 163 | + cmr.elastic-utils.config/gran-elastic-name |
| 164 | + cmr.elastic-utils.config/non-gran-elastic-name) |
| 165 | + num-concepts (bulk-index-concept-batches system concept-batches es-cluster-name) |
162 | 166 | msg (format "Indexing of %s %s revisions for provider %s completed." |
163 | 167 | num-concepts |
164 | 168 | (name concept-type) |
|
184 | 188 | "Bulk index ACLs or access groups" |
185 | 189 | [system concept-batches] |
186 | 190 | (info "Indexing concepts") |
187 | | - (ac-bulk-index/bulk-index-with-revision-date {:system (helper/get-indexer system)} concept-batches)) |
| 191 | + (ac-bulk-index/bulk-index-with-revision-date {:system (helper/get-indexer system)} concept-batches cmr.elastic-utils.config/non-gran-elastic-name)) |
188 | 192 |
|
189 | 193 | (defn- index-concepts |
190 | 194 | "Bulk index the given concepts using the indexer-app" |
191 | | - [system concept-batches] |
| 195 | + [system concept-batches es-cluster-name] |
192 | 196 | (info "Indexing concepts") |
193 | | - (index/bulk-index-with-revision-date {:system (helper/get-indexer system)} concept-batches)) |
| 197 | + (index/bulk-index-with-revision-date {:system (helper/get-indexer system)} concept-batches es-cluster-name)) |
194 | 198 |
|
| 199 | +;; TODO CMR-10636 -- This whole series of index funcs need to be tested thoroughly. |
195 | 200 | (defn- fetch-and-index-new-concepts |
196 | 201 | "Get batches of concepts for a given provider/concept type that have a revision-date |
197 | 202 | newer than the given date time and then index them." |
|
206 | 211 | params) |
207 | 212 | concept-batches (db/find-concepts-in-batches |
208 | 213 | db provider params (:db-batch-size system)) |
| 214 | + es-cluster-name (if (= concept-type :granule) |
| 215 | + cmr.elastic-utils.config/gran-elastic-name |
| 216 | + cmr.elastic-utils.config/non-gran-elastic-name) |
| 217 | + _ (println "INSIDE fetch-and-index-new-concepts with concept-type = " concept-type " and concept batches = " concept-batches " and es-cluster-name = " es-cluster-name) |
209 | 218 | {:keys [max-revision-date num-indexed]} (if (contains? #{:acl :access-group} concept-type) |
210 | 219 | (index-access-control-concepts system concept-batches) |
211 | | - (index-concepts system concept-batches))] |
| 220 | + (index-concepts system concept-batches es-cluster-name))] |
212 | 221 |
|
213 | 222 | (info (format (str "Indexed %d %s(s) for provider %s with revision-date later than %s and max " |
214 | 223 | "revision date was %s.") |
|
242 | 251 | (defn index-concepts-by-id |
243 | 252 | "Index concepts of the given type for the given provider with the given concept-ids." |
244 | 253 | [system provider-id concept-type concept-ids] |
| 254 | + (println "INSIDE index-concepts-by-id in data/bulk_index.clj") |
245 | 255 | (let [db (helper/get-metadata-db-db system) |
246 | 256 | provider (helper/get-provider system provider-id) |
247 | 257 | ;; Oracle only allows 1000 values in an 'in' clause, so we partition here |
|
254 | 264 | {:concept-type concept-type :concept-id batch} |
255 | 265 | (:db-batch-size system))] |
256 | 266 | concept-batch) |
257 | | - total (index/bulk-index {:system (helper/get-indexer system)} concept-batches nil)] |
| 267 | + es-cluster-name (if (= :granule concept-type) |
| 268 | + cmr.elastic-utils.config/gran-elastic-name |
| 269 | + cmr.elastic-utils.config/non-gran-elastic-name) |
| 270 | + _ (println "es-cluster-name selected = " es-cluster-name " for concept-batches in index-concepts-by-id = " concept-batches) |
| 271 | + total (index/bulk-index {:system (helper/get-indexer system)} concept-batches es-cluster-name)] |
258 | 272 |
|
259 | 273 | ;; for concept types that have all revisions index, also index the all revisions index |
260 | 274 | (when-not (#{:tag :granule} concept-type) |
|
0 commit comments