|
185 | 185 |
|
186 | 186 | (defn- science-keywords->elastic-docs
|
187 | 187 | "Convert hierarchical science-keywords to colon-separated elastic docs for indexing"
|
188 |
| - [science-keywords public-collection? permitted-group-ids modified-date] |
| 188 | + [science-keywords public-collection? permitted-group-ids] |
189 | 189 | (let [keyword-hierarchy [:topic :term :variable-level-1
|
190 | 190 | :variable-level-2 :variable-level-3 :detailed-variable]
|
191 | 191 | sk-strings (->> keyword-hierarchy
|
|
202 | 202 | :fields keyword-string
|
203 | 203 | :_index "1_autocomplete"
|
204 | 204 | :contains-public-collections public-collection?
|
205 |
| - :permitted-group-ids permitted-group-ids |
206 |
| - :modified modified-date})) |
| 205 | + :permitted-group-ids permitted-group-ids})) |
207 | 206 |
|
208 | 207 | (defn- suggestion-doc
|
209 | 208 | "Creates elasticsearch docs from a given humanized map"
|
|
218 | 217 | permitted-group-ids (->> permissions
|
219 | 218 | (remove #(= "guest" %))
|
220 | 219 | (s/join ",")
|
221 |
| - not-empty) |
222 |
| - modified-date (str (t/now))] |
| 220 | + not-empty)] |
223 | 221 | (if (seq (re-find sk-matcher))
|
224 |
| - (science-keywords->elastic-docs |
225 |
| - value-map |
226 |
| - public-collection? |
227 |
| - permitted-group-ids |
228 |
| - modified-date) |
| 222 | + (science-keywords->elastic-docs value-map public-collection? permitted-group-ids) |
229 | 223 | (map (fn [value]
|
230 | 224 | (let [v (val value)
|
231 | 225 | type (-> key-name
|
|
240 | 234 | :fields v
|
241 | 235 | :_index "1_autocomplete"
|
242 | 236 | :contains-public-collections public-collection?
|
243 |
| - :permitted-group-ids permitted-group-ids |
244 |
| - :modified modified-date})) |
| 237 | + :permitted-group-ids permitted-group-ids})) |
245 | 238 | values))))
|
246 | 239 |
|
247 | 240 | (defn- get-suggestion-docs
|
|
326 | 319 | flatten)]
|
327 | 320 | (es/bulk-index-autocomplete-suggestions context latest-suggestion-batches)))
|
328 | 321 |
|
329 |
| -(defn- prune-stale-autocomplete-suggestions |
330 |
| - "Delete any autocomplete suggestions that were modified longer than a day ago" |
331 |
| - [context] |
332 |
| - (info "Pruning autocomplete suggestions") |
333 |
| - (let [{:keys [index-names]} (idx-set/get-concept-type-index-names context) |
334 |
| - index (vals (:suggestion index-names)) |
335 |
| - concept-mapping-types (idx-set/get-concept-mapping-types context) |
336 |
| - mapping-type (concept-mapping-types :collection)] |
337 |
| - (es/delete-by-query |
338 |
| - context |
339 |
| - index |
340 |
| - mapping-type |
341 |
| - {:range {(query-field->elastic-field :modified :suggestion) {:lt "now-24h/h"}}}))) |
342 |
| - |
343 | 322 | (defn reindex-autocomplete-suggestions
|
344 | 323 | "Reindexes all autocomplete suggestions in the providers given."
|
345 | 324 | [context]
|
|
349 | 328 | (reindex-autocomplete-suggestions-for-provider context provider-id)
|
350 | 329 | (catch Exception e (error (format "An error occurred while reindexing autocomplete suggestions in provider [%s] : %s"
|
351 | 330 | provider-id
|
352 |
| - (.getMessage e)))))) |
353 |
| - (try |
354 |
| - (prune-stale-autocomplete-suggestions context) |
355 |
| - (catch Exception e |
356 |
| - (error (format "An error occurred while cleaning up autocomplete suggesions %s" |
357 |
| - (.getMessage e))))))) |
| 331 | + (.getMessage e)))))))) |
358 | 332 |
|
359 | 333 | (defn reindex-provider-collections
|
360 | 334 | "Reindexes all the collections in the providers given.
|
|
0 commit comments