Skip to content

Commit

Permalink
Support for create_node_index and drop_node_index in batch
Browse files Browse the repository at this point in the history
  • Loading branch information
calamitas committed Nov 13, 2013
1 parent d8cadbd commit 30cf86e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/neography/rest/batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
17 changes: 17 additions & 0 deletions spec/integration/rest_batch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 30cf86e

Please sign in to comment.