diff --git a/src/clojure/monger/collection.clj b/src/clojure/monger/collection.clj index 0b9a73a..ec2c98d 100644 --- a/src/clojure/monger/collection.clj +++ b/src/clojure/monger/collection.clj @@ -544,9 +544,10 @@ EXAMPLES ;; create a regular index - (monger.collection/ensure-index \"documents\" {\"language\" 1}) + ;; clojure.core/array-map produces an ordered map + (monger.collection/ensure-index \"documents\" (array-map \"language\" 1)) ;; create a unique index - (monger.collection/ensure-index \"pages\" {:url 1} {:unique true}) + (monger.collection/ensure-index \"pages\" (array-map :url 1) {:unique true}) " ([^String collection ^Map keys] (.ensureIndex (.getCollection monger.core/*mongodb-database* (name collection)) (as-field-selector keys))) diff --git a/test/monger/test/full_text_search_test.clj b/test/monger/test/full_text_search_test.clj index 5b61680..3af94c4 100644 --- a/test/monger/test/full_text_search_test.clj +++ b/test/monger/test/full_text_search_test.clj @@ -20,7 +20,7 @@ (deftest ^{:edge-features true :search true} test-basic-full-text-search-query (let [coll "docs"] - (mc/ensure-index coll {:subject "text" :content "text"}) + (mc/ensure-index coll (array-map :subject "text" :content "text")) (mc/insert coll {:subject "hello there" :content "this should be searchable"}) (mc/insert coll {:subject "untitled" :content "this is just noize"}) (let [res (ms/search coll "hello") diff --git a/test/monger/test/indexing_test.clj b/test/monger/test/indexing_test.clj index a40e79a..7753ef5 100644 --- a/test/monger/test/indexing_test.clj +++ b/test/monger/test/indexing_test.clj @@ -26,11 +26,11 @@ (mc/create-index collection ["language"]) (mc/drop-index collection "language_1") (is (nil? (second (mc/indexes-on collection)))) - (mc/ensure-index collection { "language" 1 } {:unique true}) + (mc/ensure-index collection (array-map "language" 1) {:unique true}) (is (= "language_1" (:name (second (mc/indexes-on collection))))) - (mc/ensure-index collection { "language" 1 }) - (mc/ensure-index collection { "language" 1 } { :unique true }) + (mc/ensure-index collection (array-map "language" 1)) + (mc/ensure-index collection (array-map "language" 1) { :unique true }) (mc/drop-indexes collection))) (deftest ^{:indexing true :edge-features true :time-consuming true} test-ttl-collections @@ -38,7 +38,7 @@ ttl 30 sleep 120] (mc/remove coll) - (mc/ensure-index coll {:created-at 1} {:expireAfterSeconds ttl}) + (mc/ensure-index coll (array-map :created-at 1) {:expireAfterSeconds ttl}) (dotimes [i 100] (mc/insert coll {:type "signup" :created-at (-> i secs ago) :i i})) (dotimes [i 100]