From 30cf86e5ace7f51bae7c8e0e6c88706d5a8296a2 Mon Sep 17 00:00:00 2001 From: Peter Vanbroekhoven Date: Tue, 29 Oct 2013 11:42:17 +0100 Subject: [PATCH] Support for create_node_index and drop_node_index in batch --- lib/neography/rest/batch.rb | 15 +++++++++++++++ spec/integration/rest_batch_spec.rb | 17 +++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/lib/neography/rest/batch.rb b/lib/neography/rest/batch.rb index 9c6bd05..b05b80a 100644 --- a/lib/neography/rest/batch.rb +++ b/lib/neography/rest/batch.rb @@ -54,6 +54,21 @@ def create_node(body) # NodeIndexes + def create_node_index(name, type = "exact", provider = "lucene") + post NodeIndexes.all_path do + { :name => name, + :config => { + :type => type, + :provider => provider + } + } + end + end + + def drop_node_index(index) + delete NodeIndexes.unique_path(:index => index) + end + def create_unique_node(index, key, value, properties) post NodeIndexes.unique_path(:index => index) do { diff --git a/spec/integration/rest_batch_spec.rb b/spec/integration/rest_batch_spec.rb index 87acdcf..5ff0d3c 100644 --- a/spec/integration/rest_batch_spec.rb +++ b/spec/integration/rest_batch_spec.rb @@ -210,6 +210,23 @@ existing_relationship["self"].should == new_relationship["self"] end + it "can drop a node index" do + index_name = generate_text(6) + @neo.create_node_index(index_name) + @neo.batch [:drop_node_index, index_name] + @neo.list_node_indexes[index_name].should be_nil + end + + it "can create a node index" do + index_name = generate_text(6) + @neo.batch [:create_node_index, index_name, "fulltext", "lucene"] + indexes = @neo.list_node_indexes + index = indexes[index_name] + index.should_not be_nil + index["provider"].should == "lucene" + index["type"].should == "fulltext" + end + it "can add a node to an index" do index_name = generate_text(6) new_node = @neo.create_node