Skip to content

Commit

Permalink
URL-encode document ids, closes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelklishin committed Sep 22, 2012
1 parent 1ae1e6b commit 967acb2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions 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`.
Expand Down
4 changes: 2 additions & 2 deletions src/clojurewerkz/elastisch/rest.clj
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
9 changes: 6 additions & 3 deletions test/clojurewerkz/elastisch/rest_api/get_test.clj
Expand Up @@ -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
;;
Expand Down

0 comments on commit 967acb2

Please sign in to comment.