Skip to content
Browse files

URL-encode document ids, closes #4

  • Loading branch information...
1 parent 1ae1e6b commit 967acb2463c10e8cf6a5dc31f283ee529842aee7 @michaelklishin michaelklishin committed
Showing with 13 additions and 5 deletions.
  1. +5 −0 ChangeLog.md
  2. +2 −2 src/clojurewerkz/elastisch/rest.clj
  3. +6 −3 test/clojurewerkz/elastisch/rest_api/get_test.clj
View
5 ChangeLog.md
@@ -1,5 +1,10 @@
## Changes between Elastisch 1.0.0-rc2 and 1.0.0
+### URL-encoded Document IDs
+
+Elastisch will now URL-encode document ids.
+
+
### clj-http Update
[clj-http](https://github.com/dakrone/clj-http/) dependency has been upgraded to version `0.5.4`.
View
4 src/clojurewerkz/elastisch/rest.clj
@@ -77,7 +77,7 @@
(defn record-url
[^String index-name ^String type id]
- (url-with-path index-name type id))
+ (url-with-path index-name type (URLEncoder/encode id encoding)))
(defn index-mapping-url
@@ -179,7 +179,7 @@
(defn more-like-this-url
[^String index-name ^String mapping-type id]
- (url-with-path index-name mapping-type id "_mlt"))
+ (url-with-path index-name mapping-type (URLEncoder/encode id encoding) "_mlt"))
(defn percolator-url
[^String index-name ^String percolator]
View
9 test/clojurewerkz/elastisch/rest_api/get_test.clj
@@ -21,19 +21,22 @@
(deftest test-get-with-non-existing-document
(is (nil? (doc/get index-name index-type "1"))))
+(deftest ^:focus test-get-with-existing-id-that-needs-url-encoding
+ (let [id "http://www.faz.net/artikel/C31325/piratenabwehr-keine-kriegswaffen-fuer-private-dienste-30683040.html"]
+ (doc/put index-name index-type id fx/person-jack)
+ (is (doc/get index-name index-type id))))
;;
;; present?
;;
-(deftest test-present-on-non-existing-id
+(deftest test-present-with-non-existing-id
(is (not (doc/present? index-name index-type "1"))))
-(deftest test-present-on-existing-id
+(deftest test-present-with-existing-id
(doc/put index-name index-type "1" fx/person-jack)
(is (doc/present? index-name index-type "1")))
-
;;
;; count
;;

0 comments on commit 967acb2

Please sign in to comment.
Something went wrong with that request. Please try again.