From d9d524ad41070129866dae509a39f26229cd37eb Mon Sep 17 00:00:00 2001 From: Max De Marzi Date: Sun, 3 Jun 2012 00:50:52 -0500 Subject: [PATCH] creating auto node and relationship commands, tests not done yet --- README.rdoc | 6 +++++- lib/neography/rest.rb | 24 ++++++++++++++++++++++++ spec/integration/rest_index_spec.rb | 19 +++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/README.rdoc b/README.rdoc index b3250de..af8e43d 100644 --- a/README.rdoc +++ b/README.rdoc @@ -150,7 +150,9 @@ To Use: @neo.remove_node_from_index(index, node1) # removes a node from the index @neo.get_node_index(index, key, value) # exact query of the node index with the given key/value pair @neo.find_node_index(index, key, value) # advanced query of the node index with the given key/value pair - @neo.find_node_index(index, query ) # advanced query of the node index with the given query + @neo.find_node_index(index, query) # advanced query of the node index with the given query + @neo.get_node_auto_index(key, value) # exact query of the node auto index with the given key/value pair + @neo.find_node_auto_index(query) # advanced query of the node auto index with the given query @neo.list_relationship_indexes # gives names and query templates for relationship indices @neo.create_relationship_index(name, "fulltext", provider) # creates a relationship index with "fulltext" option @neo.add_relationship_to_index(index, key, value, rel1) # adds a relationship to the index with the given key/value pair @@ -160,6 +162,8 @@ To Use: @neo.get_relationship_index(index, key, value) # exact query of the relationship index with the given key/value pair @neo.find_relationship_index(index, key, value) # advanced query of the relationship index with the given key/value pair @neo.find_relationship_index(index, query) # advanced query of the relationship index with the given query + @neo.get_relationship_auto_index(key, value) # exact query of the relationship auto index with the given key/value pair + @neo.find_relationship_auto_index(query) # advanced query of the relationship auto index with the given query @neo.execute_script("g.v(0)") # sends a Groovy script (through the Gremlin plugin) @neo.execute_script("g.v(id)", {:id => 3}) # sends a parameterized Groovy script (optimized for repeated calls) @neo.execute_query("start n=node(0) return n") # sends a Cypher query (through the Cypher plugin) diff --git a/lib/neography/rest.rb b/lib/neography/rest.rb index 776c94e..06d9b3e 100644 --- a/lib/neography/rest.rb +++ b/lib/neography/rest.rb @@ -294,6 +294,18 @@ def get_node_index(index, key, value) index end + def get_node_auto_index(key, value) + index = get("/index/auto/node/#{key}/#{value}") || Array.new + return nil if index.empty? + index + end + + def find_node_auto_index(query) + index = get("/index/auto/node/?query=#{query}") || Array.new + return nil if index.empty? + index + end + def find_node_index(*args) case args.size when 3 then index = get("/index/node/#{args[0]}/#{args[1]}?query=#{args[2]}") || Array.new @@ -345,6 +357,18 @@ def find_relationship_index(*args) index end + def get_relationship_auto_index(key, value) + index = get("/index/auto/relationship/#{key}/#{value}") || Array.new + return nil if index.empty? + index + end + + def find_relationship_auto_index(query) + index = get("/index/auto/relationship/?query=#{query}") || Array.new + return nil if index.empty? + index + end + def traverse(id, return_type, description) options = { :body => {"order" => get_order(description["order"]), "uniqueness" => get_uniqueness(description["uniqueness"]), diff --git a/spec/integration/rest_index_spec.rb b/spec/integration/rest_index_spec.rb index a2d6414..08720c9 100644 --- a/spec/integration/rest_index_spec.rb +++ b/spec/integration/rest_index_spec.rb @@ -293,5 +293,24 @@ end + describe "auto indexes" do + + it "can get a node from an automatic index" do + pending + end + + it "can query a node from an automatic index" do + pending + end + + it "can get a relationship from an automatic index" do + pending + end + + it "can query a relationship from an automatic index" do + pending + end + + end end \ No newline at end of file