Fetching contributors…
Cannot retrieve contributors at this time
50 lines (43 sloc) 2.24 KB
;; Copyright (c) 2011-2015 Michael S. Klishin, Alex Petrov, and The ClojureWerkz
;; Team
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
"Operations on indices (Neo4J 2.0+ only)."
(:require [ :as rest]
[cheshire.core :as json]
[ :as conv]
[ :refer [missing?]])
(:import [ Connection])
(:refer-clojure :exclude [drop]))
(defn- get-url
[^Connection connection label]
(str (get-in connection [:endpoint :uri]) "schema/index/" (conv/kw-to-string label)))
(defn create
"Creates an index on a given label and property.
[^Connection connection label property]
(let [req-body (json/encode {"property_keys" [(conv/kw-to-string property)]})
{:keys [status headers body]} (rest/POST connection (get-url connection label)
:body req-body)]
(when-not (missing? status)
(json/decode body true)
(defn get-all
"Gets all indices for a given label.
[^Connection connection label]
(let [{:keys [status headers body]} (rest/GET connection (get-url connection label))]
(when-not (missing? status)
(json/decode body true))))
(defn drop
"Drops an index on an existing label and property.
[^Connection connection label property]
(rest/DELETE connection (str (get-url connection label) "/" (conv/kw-to-string property))))