Skip to content

Commit 3aaa386

Browse files
committed
Revert "CMR-7185: prune old autocomplete suggestions"
This reverts commit fef2cc0.
1 parent 457d76c commit 3aaa386

File tree

3 files changed

+7
-66
lines changed

3 files changed

+7
-66
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,7 @@
704704
:fields (m/not-indexed m/string-field-mapping)
705705
:value m/search-as-you-type-field-mapping
706706
:contains-public-collections (m/doc-values m/bool-field-mapping)
707-
:permitted-group-ids (m/doc-values m/string-field-mapping)
708-
:modified (m/doc-values m/date-field-mapping)})
707+
:permitted-group-ids (m/doc-values m/string-field-mapping)})
709708

710709
(defmapping variable-mapping :variable
711710
"Defines the elasticsearch mapping for storing variables. These are the

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

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@
185185

186186
(defn- science-keywords->elastic-docs
187187
"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]
189189
(let [keyword-hierarchy [:topic :term :variable-level-1
190190
:variable-level-2 :variable-level-3 :detailed-variable]
191191
sk-strings (->> keyword-hierarchy
@@ -202,8 +202,7 @@
202202
:fields keyword-string
203203
:_index "1_autocomplete"
204204
:contains-public-collections public-collection?
205-
:permitted-group-ids permitted-group-ids
206-
:modified modified-date}))
205+
:permitted-group-ids permitted-group-ids}))
207206

208207
(defn- suggestion-doc
209208
"Creates elasticsearch docs from a given humanized map"
@@ -218,14 +217,9 @@
218217
permitted-group-ids (->> permissions
219218
(remove #(= "guest" %))
220219
(s/join ",")
221-
not-empty)
222-
modified-date (str (t/now))]
220+
not-empty)]
223221
(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)
229223
(map (fn [value]
230224
(let [v (val value)
231225
type (-> key-name
@@ -240,8 +234,7 @@
240234
:fields v
241235
:_index "1_autocomplete"
242236
:contains-public-collections public-collection?
243-
:permitted-group-ids permitted-group-ids
244-
:modified modified-date}))
237+
:permitted-group-ids permitted-group-ids}))
245238
values))))
246239

247240
(defn- get-suggestion-docs
@@ -326,20 +319,6 @@
326319
flatten)]
327320
(es/bulk-index-autocomplete-suggestions context latest-suggestion-batches)))
328321

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-
343322
(defn reindex-autocomplete-suggestions
344323
"Reindexes all autocomplete suggestions in the providers given."
345324
[context]
@@ -349,12 +328,7 @@
349328
(reindex-autocomplete-suggestions-for-provider context provider-id)
350329
(catch Exception e (error (format "An error occurred while reindexing autocomplete suggestions in provider [%s] : %s"
351330
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))))))))
358332

359333
(defn reindex-provider-collections
360334
"Reindexes all the collections in the providers given.

system-int-test/test/cmr/system_int_test/search/autocomplete/suggestion_reindex_test.clj

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
(ns cmr.system-int-test.search.autocomplete.suggestion-reindex-test
22
"This tests re-indexes autocomplete suggestions."
33
(:require
4-
[clj-time.core :as time]
54
[clojure.test :refer :all]
65
[cmr.common.util :as util :refer [are3]]
76
[cmr.mock-echo.client.echo-util :as e]
87
[cmr.system-int-test.data2.collection :as dc]
98
[cmr.system-int-test.data2.core :as d]
109
[cmr.system-int-test.data2.umm-spec-collection :as data-umm-spec]
11-
[cmr.system-int-test.utils.dev-system-util :as dev-sys-util]
1210
[cmr.system-int-test.data2.umm-spec-common :as umm-spec-common]
1311
[cmr.system-int-test.search.facets.facets-util :as fu]
1412
[cmr.system-int-test.system :as s]
@@ -234,33 +232,3 @@
234232

235233
"does not filter 'not' prefixed values"
236234
"not" [{:value "Nothofagus" :type "science_keywords" :fields "Biosphere:Nothofagus"}])))
237-
238-
(deftest prune-stale-data-test
239-
(testing "The suggestions from these old collections shouldn't be found"
240-
(are3
241-
[query expected]
242-
(let [_ (dev-sys-util/freeze-time! "2020-01-01T10:00:00Z")
243-
coll7 (d/ingest-umm-spec-collection
244-
"PROV1"
245-
(data-umm-spec/collection
246-
{:ShortName "This one is old and should be cleaned up"
247-
:EntryTitle "Oldie"
248-
:Projects (:Projects (fu/projects "OLD"))
249-
:Platforms (:Platforms (fu/platforms "STALE" 2 2 1))}))
250-
251-
_ (dev-sys-util/freeze-time! (time/yesterday))
252-
coll8 (d/ingest-umm-spec-collection
253-
"PROV2"
254-
(data-umm-spec/collection
255-
{:ShortName "Yesterday's news"
256-
:EntryTitle "Also an Oldie"
257-
:Platforms (:Platforms (fu/platforms "old AND stale" 2 1 1))}))
258-
_(index/wait-until-indexed)
259-
_ (dev-sys-util/clear-current-time!)
260-
results (get-in (search/get-autocomplete-json (str "q=" query)) [:feed :entry])]
261-
(compare-autocomplete-results results expected))
262-
"None found"
263-
"stale" []
264-
265-
"Still none found"
266-
"old" [])))

0 commit comments

Comments
 (0)