diff --git a/README.rdoc b/README.rdoc index 779cde7..79bc834 100644 --- a/README.rdoc +++ b/README.rdoc @@ -19,7 +19,7 @@ in order to access the functionality. === Try it now! -I am hosting an instance of Neo4j (1.2) at neography.org for you to try out. +I am hosting an instance of Neo4j (1.3M04) at neography.org for you to try out. You can see the administration at: {Neo4j Web Admin}[http://neography.org] @@ -99,11 +99,15 @@ To Use: @neo.create_node_index(name, type, provider) # creates an index, defaults are "exact" and "lucene" @neo.add_node_to_index(index, key, value, node1) # adds a node to the index with the given key/value pair @neo.remove_node_from_index(index, key, value, node1) # removes a node from the index with the given key/value pair + @neo.remove_node_from_index(index, key, node1) # removes a node from the index with the given key + @neo.remove_node_from_index(index, node1) # removes a node from the index @neo.get_node_index(index, key, value) # queries the index with the given key/value pair @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 @neo.remove_relationship_from_index(index, key, value, rel1) # removes a relationship from the index with the given key/value pair + @neo.remove_relationship_from_index(index, key, rel1) # removes a relationship from the index with the given key + @neo.remove_relationship_from_index(index, rel1) # removes a relationship from the index @neo.get_relationship_index(index, key, value) # queries the relationship index with the given key/value pair diff --git a/lib/neography/rest.rb b/lib/neography/rest.rb index 9048913..3b31b2c 100644 --- a/lib/neography/rest.rb +++ b/lib/neography/rest.rb @@ -248,8 +248,12 @@ def add_node_to_index(index, key, value, id) post("/index/node/#{index}/#{key}/#{value}", options) end - def remove_node_from_index(index, key, value, id) - delete("/index/node/#{index}/#{key}/#{value}/#{get_id(id)}") + def remove_node_from_index(*args) + case args.size + when 4 then delete("/index/node/#{args[0]}/#{args[1]}/#{args[2]}/#{get_id(args[3])}") + when 3 then delete("/index/node/#{args[0]}/#{args[1]}/#{get_id(args[2])}") + when 2 then delete("/index/node/#{args[0]}/#{get_id(args[1])}") + end end def get_node_index(index, key, value) @@ -277,8 +281,12 @@ def add_relationship_to_index(index, key, value, id) post("/index/relationship/#{index}/#{key}/#{value}", options) end - def remove_relationship_from_index(index, key, value, id) - delete("/index/relationship/#{index}/#{key}/#{value}/#{get_id(id)}") + def remove_relationship_from_index(*args) + case args.size + when 4 then delete("/index/relationship/#{args[0]}/#{args[1]}/#{args[2]}/#{get_id(args[3])}") + when 3 then delete("/index/relationship/#{args[0]}/#{args[1]}/#{get_id(args[2])}") + when 2 then delete("/index/relationship/#{args[0]}/#{get_id(args[1])}") + end end def get_relationship_index(index, key, value) diff --git a/spec/integration/rest_index_spec.rb b/spec/integration/rest_index_spec.rb index 4ba24c6..5e8247e 100644 --- a/spec/integration/rest_index_spec.rb +++ b/spec/integration/rest_index_spec.rb @@ -102,6 +102,30 @@ new_index.should be_nil end + it "can remove a node from an index without supplying value" do + new_node = @neo.create_node + key = generate_text(6) + value = generate_text + @neo.add_node_to_index("test_index", key, value, new_node) + new_index = @neo.get_node_index("test_index", key, value) + new_index.should_not be_nil + @neo.remove_node_from_index("test_index", key, new_node) + new_index = @neo.get_node_index("test_index", key, value) + new_index.should be_nil + end + + it "can remove a node from an index without supplying key nor value" do + new_node = @neo.create_node + key = generate_text(6) + value = generate_text + @neo.add_node_to_index("test_index", key, value, new_node) + new_index = @neo.get_node_index("test_index", key, value) + new_index.should_not be_nil + @neo.remove_node_from_index("test_index", new_node) + new_index = @neo.get_node_index("test_index", key, value) + new_index.should be_nil + end + it "can remove a relationshp from an index" do new_node1 = @neo.create_node new_node2 = @neo.create_node @@ -115,6 +139,34 @@ new_index = @neo.get_relationship_index("test_index", key, value) new_index.should be_nil end + + it "can remove a relationshp from an index without supplying value" do + new_node1 = @neo.create_node + new_node2 = @neo.create_node + new_relationship = @neo.create_relationship("friends", new_node1, new_node2) + key = generate_text(6) + value = generate_text + @neo.add_relationship_to_index("test_index", key, value, new_relationship) + new_index = @neo.get_relationship_index("test_index", key, value) + new_index.should_not be_nil + @neo.remove_relationship_from_index("test_index", key, new_relationship) + new_index = @neo.get_relationship_index("test_index", key, value) + new_index.should be_nil + end + + it "can remove a relationshp from an index without supplying key nor value" do + new_node1 = @neo.create_node + new_node2 = @neo.create_node + new_relationship = @neo.create_relationship("friends", new_node1, new_node2) + key = generate_text(6) + value = generate_text + @neo.add_relationship_to_index("test_index", key, value, new_relationship) + new_index = @neo.get_relationship_index("test_index", key, value) + new_index.should_not be_nil + @neo.remove_relationship_from_index("test_index", new_relationship) + new_index = @neo.get_relationship_index("test_index", key, value) + new_index.should be_nil + end end describe "get index" do