   "This tests re-indexes autocomplete suggestions."
   (:require
    [clojure.test :refer :all]
+   [cmr.common.util :as util :refer [are3]]
    [cmr.mock-echo.client.echo-util :as e]
    [cmr.system-int-test.data2.collection :as dc]
    [cmr.system-int-test.data2.core :as d]

                            {:DataCenters [(data-umm-spec/data-center {:Roles ["ARCHIVER"] :ShortName "DOI/USGS/CMG/WHSC"})]
                             :ScienceKeywords [(:ScienceKeywords (fu/science-keywords sk1 sk2))]})
        coll3 (d/ingest-concept-with-metadata-file "CMR-6287/C1000000029-EDF_OPS.xml"
                                                         {:provider-id "PROV1"
                                                          :concept-type :collection
                                                          :format-key :echo10})
        _ (index/wait-until-indexed)]

    (index/reindex-suggestions)
    (index/wait-until-indexed)
    (testing "Ensure that response is in proper format and results are correct"
      (compare-autocomplete-results
        (get-in (search/get-autocomplete-json "q=level2") [:feed :entry])
        [{:score 0.25604635 :type "organization" :value "Langley DAAC User Services" :fields "Langley DAAC User Services"}
         {:score 0.041718055 :type "instrument" :value "lVIs" :fields "lVIs"}]))
    (testing "Ensure science keywords are being indexed properly"
        (compare-autocomplete-results
         (get-in (search/get-autocomplete-json "q=solar") [:feed :entry])
         [{:score 3.4995544, :type "science_keywords", :value "Solar Irradiance", :fields "Sun-Earth Interactions:Solar Activity:Solar Irradiance"}
          {:score 1.9641972, :type "science_keywords", :value "Solar Irradiance", :fields "Atmosphere:Atmospheric Radiation:Solar Irradiance"}
          {:score 0.20964509, :type "organization", :value "ACRIM SCF", :fields "ACRIM SCF"}
          {:score 0.16771607, :type "organization", :value "Langley DAAC User Services", :fields "Langley DAAC User Services"}])
        (compare-autocomplete-results
         (get-in (search/get-autocomplete-json "q=solar irradiation") [:feed :entry])
         [{:score 5.0869484, :type "science_keywords", :value "Solar Irradiance", :fields "Sun-Earth Interactions:Solar Activity:Solar Irradiance"}
          {:score 2.7943783, :type "science_keywords", :value "Solar Irradiance", :fields "Atmosphere:Atmospheric Radiation:Solar Irradiance"}
          {:score 0.061936468, :type "organization", :value "ACRIM SCF", :fields "ACRIM SCF"}
          {:score 0.049549174, :type "organization", :value "Langley DAAC User Services", :fields "Langley DAAC User Services"}]))))

             :Fees "None currently"
             :Format "NetCDF-3"}]})

(defn autocomplete-reindex-fixture
  [f]
  (let [coll1 (d/ingest "PROV1"
                        (dc/collection
                         {:DataCenters [(data-umm-spec/data-center {:Roles ["ARCHIVER"] :ShortName "DOI/USGS/CMG/WHSC"})]
                          :ArchiveAndDistributionInformation gdf1
                          :SpatialKeywords ["DC" "Miami"]
                          :ProcessingLevelId (:ProcessingLevelId (fu/processing-level-id "PL1"))
                          :Projects [(:Projects (fu/projects "proj1" "PROJ2"))]
                          :Platforms [(:Platforms (fu/platforms fu/FROM_KMS 2 2 1))]
                          :ScienceKeywords [(:ScienceKeywords (fu/science-keywords sk1 sk2))]}))

        coll2 (fu/make-coll 2 "PROV1"
                            (fu/science-keywords sk1 sk3)
