Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support for index queries and support for calling index search

functions with index as a keyword/string.
  • Loading branch information...
commit bfdc5f5f7aa971b0c982725505d02407e45236bf 1 parent 08a8017
Anderson De Andrade authored
Showing with 79 additions and 8 deletions.
  1. +79 −8 src/neo4j_clj/core.clj
View
87 src/neo4j_clj/core.clj
@@ -214,16 +214,87 @@
(.add index node (name k) v)
node)
-(defn get-hit
- [index k v]
- (.. index
- (get (name k) v)
- getSingle))
+(defn- search-node-index
+ [index]
+ (if (or (instance? String index) (instance? clojure.lang.Keyword index))
+ (create-node-index index)
+ index))
+
+(defn- search-relationship-index
+ [index]
+ (if (or (instance? String index) (instance? clojure.lang.Keyword index))
+ (create-relationship-index index)
+ index))
+
+(defn- get-hits
+ [results]
+ (seq results))
-(defn get-hits
+(defn- get-hit
+ [results]
+ (.getSingle results))
+
+(defn- get-relationship-results
+ [index k v]
+ (let [index (search-relationship-index index)]
+ (.get index (name k) v)))
+
+(defn get-relationship-hits
+ [& args]
+ (get-hits (apply get-relationship-results args)))
+
+(defn get-relationship-hit
+ [& args]
+ (get-hit (apply get-relationship-results args)))
+
+(defn- query-relationship-results
+ ([index q]
+ (query-relationship-results index q nil nil))
+ ([index k q]
+ (query-relationship-results index k q nil nil))
+ ([index q start-node end-node]
+ (let [index (search-relationship-index index)]
+ (.query index q start-node end-node)))
+ ([index k q start-node end-node]
+ (let [index (search-relationship-index index)]
+ (.query index (name k) q start-node end-node))))
+
+(defn query-relationship-hits
+ [& args]
+ (get-hits (apply query-relationship-results args)))
+
+(defn query-relationship-hit
+ [& args]
+ (get-hit (apply query-relationship-results args)))
+
+(defn- get-node-results
[index k v]
- (seq (.. index
- (get (name k) v))))
+ (let [index (search-node-index index)]
+ (.get index (name k) v)))
+
+(defn get-node-hits
+ [& args]
+ (get-hits (apply get-node-results args)))
+
+(defn get-node-hit
+ [& args]
+ (get-hit (apply get-node-results args)))
+
+(defn- query-node-results
+ ([index q]
+ (let [index (search-node-index index)]
+ (.query index q)))
+ ([index k q]
+ (let [index (search-node-index index)]
+ (.query index (name k) q))))
+
+(defn query-node-hits
+ [& args]
+ (get-hits (apply query-node-results args)))
+
+(defn query-node-hit
+ [& args]
+ (get-hit (apply query-node-results args)))
;;; --------------------------------------------------------------------------------
;; Cypher Interface

0 comments on commit bfdc5f5

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