Skip to content

Commit

Permalink
creating auto node and relationship commands, tests not done yet
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdemarzi committed Jun 3, 2012
1 parent fcf7c3b commit d9d524a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
24 changes: 24 additions & 0 deletions lib/neography/rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]),
Expand Down
19 changes: 19 additions & 0 deletions spec/integration/rest_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d9d524a

Please sign in to comment.