neography-down 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.project +12 -0
- data/.rspec +1 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +939 -0
- data/CONTRIBUTORS +18 -0
- data/Gemfile +4 -0
- data/Guardfile +14 -0
- data/LICENSE +19 -0
- data/README.md +281 -0
- data/Rakefile +14 -0
- data/examples/facebook.rb +40 -0
- data/examples/facebook_v2.rb +25 -0
- data/examples/greatest.rb +43 -0
- data/examples/linkedin.rb +39 -0
- data/examples/linkedin_v2.rb +22 -0
- data/examples/traversal_example1.rb +65 -0
- data/examples/traversal_example2.rb +54 -0
- data/lib/neography.rb +45 -0
- data/lib/neography/config.rb +64 -0
- data/lib/neography/connection.rb +263 -0
- data/lib/neography/equal.rb +21 -0
- data/lib/neography/errors.rb +60 -0
- data/lib/neography/index.rb +52 -0
- data/lib/neography/multi_json_parser.rb +28 -0
- data/lib/neography/neography.rb +10 -0
- data/lib/neography/node.rb +63 -0
- data/lib/neography/node_path.rb +29 -0
- data/lib/neography/node_relationship.rb +37 -0
- data/lib/neography/node_traverser.rb +146 -0
- data/lib/neography/path_traverser.rb +100 -0
- data/lib/neography/property.rb +110 -0
- data/lib/neography/property_container.rb +28 -0
- data/lib/neography/railtie.rb +19 -0
- data/lib/neography/relationship.rb +78 -0
- data/lib/neography/relationship_traverser.rb +80 -0
- data/lib/neography/rest.rb +99 -0
- data/lib/neography/rest/batch.rb +414 -0
- data/lib/neography/rest/clean.rb +17 -0
- data/lib/neography/rest/constraints.rb +38 -0
- data/lib/neography/rest/cypher.rb +29 -0
- data/lib/neography/rest/extensions.rb +21 -0
- data/lib/neography/rest/gremlin.rb +20 -0
- data/lib/neography/rest/helpers.rb +96 -0
- data/lib/neography/rest/node_auto_indexes.rb +60 -0
- data/lib/neography/rest/node_indexes.rb +139 -0
- data/lib/neography/rest/node_labels.rb +49 -0
- data/lib/neography/rest/node_paths.rb +49 -0
- data/lib/neography/rest/node_properties.rb +52 -0
- data/lib/neography/rest/node_relationships.rb +33 -0
- data/lib/neography/rest/node_traversal.rb +25 -0
- data/lib/neography/rest/nodes.rb +94 -0
- data/lib/neography/rest/other_node_relationships.rb +38 -0
- data/lib/neography/rest/relationship_auto_indexes.rb +60 -0
- data/lib/neography/rest/relationship_indexes.rb +142 -0
- data/lib/neography/rest/relationship_properties.rb +52 -0
- data/lib/neography/rest/relationship_types.rb +11 -0
- data/lib/neography/rest/relationships.rb +16 -0
- data/lib/neography/rest/schema_indexes.rb +26 -0
- data/lib/neography/rest/spatial.rb +137 -0
- data/lib/neography/rest/transactions.rb +101 -0
- data/lib/neography/tasks.rb +207 -0
- data/lib/neography/version.rb +3 -0
- data/neography.gemspec +39 -0
- data/spec/integration/authorization_spec.rb +40 -0
- data/spec/integration/broken_spatial_spec.rb +28 -0
- data/spec/integration/index_spec.rb +71 -0
- data/spec/integration/neography_spec.rb +10 -0
- data/spec/integration/node_encoding_spec.rb +71 -0
- data/spec/integration/node_path_spec.rb +222 -0
- data/spec/integration/node_relationship_spec.rb +381 -0
- data/spec/integration/node_spec.rb +260 -0
- data/spec/integration/parsing_spec.rb +13 -0
- data/spec/integration/performance_spec.rb +17 -0
- data/spec/integration/relationship_spec.rb +37 -0
- data/spec/integration/rest_batch_no_streaming_spec.rb +41 -0
- data/spec/integration/rest_batch_spec.rb +604 -0
- data/spec/integration/rest_batch_streaming_spec.rb +51 -0
- data/spec/integration/rest_bulk_spec.rb +106 -0
- data/spec/integration/rest_constraints_spec.rb +72 -0
- data/spec/integration/rest_experimental_spec.rb +22 -0
- data/spec/integration/rest_gremlin_fail_spec.rb +46 -0
- data/spec/integration/rest_header_spec.rb +15 -0
- data/spec/integration/rest_index_spec.rb +481 -0
- data/spec/integration/rest_labels_spec.rb +128 -0
- data/spec/integration/rest_node_spec.rb +274 -0
- data/spec/integration/rest_other_node_relationship_spec.rb +137 -0
- data/spec/integration/rest_path_spec.rb +231 -0
- data/spec/integration/rest_plugin_spec.rb +177 -0
- data/spec/integration/rest_relationship_spec.rb +354 -0
- data/spec/integration/rest_relationship_types_spec.rb +18 -0
- data/spec/integration/rest_schema_index_spec.rb +32 -0
- data/spec/integration/rest_spatial_spec.rb +166 -0
- data/spec/integration/rest_transaction_spec.rb +166 -0
- data/spec/integration/rest_traverse_spec.rb +149 -0
- data/spec/integration/unmanaged_spec.rb +27 -0
- data/spec/matchers.rb +33 -0
- data/spec/neography_spec.rb +23 -0
- data/spec/spec_helper.rb +44 -0
- data/spec/unit/config_spec.rb +135 -0
- data/spec/unit/connection_spec.rb +284 -0
- data/spec/unit/node_spec.rb +100 -0
- data/spec/unit/properties_spec.rb +285 -0
- data/spec/unit/relationship_spec.rb +118 -0
- data/spec/unit/rest/batch_spec.rb +262 -0
- data/spec/unit/rest/clean_spec.rb +16 -0
- data/spec/unit/rest/constraints_spec.rb +45 -0
- data/spec/unit/rest/cypher_spec.rb +20 -0
- data/spec/unit/rest/extensions_spec.rb +28 -0
- data/spec/unit/rest/gremlin_spec.rb +25 -0
- data/spec/unit/rest/helpers_spec.rb +124 -0
- data/spec/unit/rest/labels_spec.rb +77 -0
- data/spec/unit/rest/node_auto_indexes_spec.rb +70 -0
- data/spec/unit/rest/node_indexes_spec.rb +140 -0
- data/spec/unit/rest/node_paths_spec.rb +77 -0
- data/spec/unit/rest/node_properties_spec.rb +79 -0
- data/spec/unit/rest/node_relationships_spec.rb +57 -0
- data/spec/unit/rest/node_traversal_spec.rb +35 -0
- data/spec/unit/rest/nodes_spec.rb +187 -0
- data/spec/unit/rest/relationship_auto_indexes_spec.rb +66 -0
- data/spec/unit/rest/relationship_indexes_spec.rb +132 -0
- data/spec/unit/rest/relationship_properties_spec.rb +79 -0
- data/spec/unit/rest/relationship_types_spec.rb +15 -0
- data/spec/unit/rest/relationships_spec.rb +21 -0
- data/spec/unit/rest/schema_index_spec.rb +30 -0
- data/spec/unit/rest/transactions_spec.rb +43 -0
- metadata +372 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Neography::Rest do
|
|
4
|
+
before(:each) do
|
|
5
|
+
@neo = Neography::Rest.new
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe "streaming" do
|
|
9
|
+
|
|
10
|
+
it "can send a 1000 item batch" do
|
|
11
|
+
commands = []
|
|
12
|
+
1000.times do |x|
|
|
13
|
+
commands << [:create_node, {"name" => "Max " + x.to_s}]
|
|
14
|
+
end
|
|
15
|
+
batch_result = @neo.batch *commands
|
|
16
|
+
expect(batch_result.first["body"]["data"]["name"]).to eq("Max 0")
|
|
17
|
+
expect(batch_result.last["body"]["data"]["name"]).to eq("Max 999")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "can send a 5000 item batch" do
|
|
21
|
+
commands = []
|
|
22
|
+
5000.times do |x|
|
|
23
|
+
commands << [:get_node, 0]
|
|
24
|
+
end
|
|
25
|
+
batch_result = @neo.batch *commands
|
|
26
|
+
expect(batch_result.first["body"]["self"].split('/').last).to eq("0")
|
|
27
|
+
expect(batch_result.last["body"]["self"].split('/').last).to eq("0")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "can send a 7000 get item batch" do
|
|
31
|
+
commands = []
|
|
32
|
+
7000.times do |x|
|
|
33
|
+
commands << [:get_node, 0]
|
|
34
|
+
end
|
|
35
|
+
batch_result = @neo.batch *commands
|
|
36
|
+
expect(batch_result.first["body"]["self"].split('/').last).to eq("0")
|
|
37
|
+
expect(batch_result.last["body"]["self"].split('/').last).to eq("0")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "can send a 5000 create item batch" do
|
|
41
|
+
commands = []
|
|
42
|
+
5000.times do |x|
|
|
43
|
+
commands << [:create_node, {"name" => "Max " + x.to_s}]
|
|
44
|
+
end
|
|
45
|
+
batch_result = @neo.batch *commands
|
|
46
|
+
expect(batch_result.first["body"]["data"]["name"]).to eq("Max 0")
|
|
47
|
+
expect(batch_result.last["body"]["data"]["name"]).to eq("Max 4999")
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Neography::Rest do
|
|
4
|
+
before(:each) do
|
|
5
|
+
@neo = Neography::Rest.new
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe "can create many nodes threaded" do
|
|
9
|
+
it "can create empty nodes threaded" do
|
|
10
|
+
new_nodes = @neo.create_nodes_threaded(2)
|
|
11
|
+
expect(new_nodes).not_to be_nil
|
|
12
|
+
expect(new_nodes.size).to eq(2)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "is faster than non-threaded?" , :slow => true do
|
|
16
|
+
Benchmark.bm do |x|
|
|
17
|
+
x.report("create 500 nodes ") { @not_threaded = @neo.create_nodes(500) }
|
|
18
|
+
x.report("create 500 nodes threaded") { @threaded = @neo.create_nodes_threaded(500) }
|
|
19
|
+
x.report("create 1000 nodes threaded") { @threaded2c = @neo.create_nodes_threaded(1000) }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
expect(@not_threaded[99]).not_to be_nil
|
|
23
|
+
expect(@threaded[99]).not_to be_nil
|
|
24
|
+
expect(@threaded2c[199]).not_to be_nil
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe "can create many nodes" do
|
|
30
|
+
it "can create empty nodes" do
|
|
31
|
+
new_nodes = @neo.create_nodes(2)
|
|
32
|
+
expect(new_nodes).not_to be_nil
|
|
33
|
+
expect(new_nodes.size).to eq(2)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "can create nodes with one property" do
|
|
37
|
+
new_nodes = @neo.create_nodes([{"name" => "Max"}, {"name" => "Alex"}])
|
|
38
|
+
expect(new_nodes[0]["data"]["name"]).to eq("Max")
|
|
39
|
+
expect(new_nodes[1]["data"]["name"]).to eq("Alex")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "can create nodes with one property that are different" do
|
|
43
|
+
new_nodes = @neo.create_nodes([{"name" => "Max"}, {"age" => 24}])
|
|
44
|
+
expect(new_nodes[0]["data"]["name"]).to eq("Max")
|
|
45
|
+
expect(new_nodes[1]["data"]["age"]).to eq(24)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "can create nodes with more than one property" do
|
|
49
|
+
new_nodes = @neo.create_nodes([{"age" => 31, "name" => "Max"}, {"age" => 24, "name" => "Alex"}])
|
|
50
|
+
expect(new_nodes[0]["data"]["name"]).to eq("Max")
|
|
51
|
+
expect(new_nodes[0]["data"]["age"]).to eq(31)
|
|
52
|
+
expect(new_nodes[1]["data"]["name"]).to eq("Alex")
|
|
53
|
+
expect(new_nodes[1]["data"]["age"]).to eq(24)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it "can create nodes with more than one property that are different" do
|
|
57
|
+
new_nodes = @neo.create_nodes([{"age" => 31, "name" => "Max"}, {"height" => "5-11", "weight" => 215}])
|
|
58
|
+
expect(new_nodes[0]["data"]["name"]).to eq("Max")
|
|
59
|
+
expect(new_nodes[0]["data"]["age"]).to eq(31)
|
|
60
|
+
expect(new_nodes[1]["data"]["height"]).to eq("5-11")
|
|
61
|
+
expect(new_nodes[1]["data"]["weight"]).to eq(215)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it "is not super slow?" , :slow => true do
|
|
65
|
+
Benchmark.bm do |x|
|
|
66
|
+
x.report( "create 1 node" ) { @neo.create_nodes( 1) }
|
|
67
|
+
x.report( "create 10 nodes") { @neo.create_nodes( 10) }
|
|
68
|
+
x.report("create 100 nodes") { @neo.create_nodes(100) }
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
describe "can get many nodes" do
|
|
74
|
+
it "can get 2 nodes passed in as an array" do
|
|
75
|
+
new_nodes = @neo.create_nodes(2)
|
|
76
|
+
existing_nodes = @neo.get_nodes(new_nodes)
|
|
77
|
+
expect(existing_nodes).not_to be_nil
|
|
78
|
+
expect(existing_nodes.size).to eq(2)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "can get 2 nodes passed in by commas" do
|
|
82
|
+
new_nodes = @neo.create_nodes(2)
|
|
83
|
+
new_node1 = new_nodes[0]["self"].split('/').last
|
|
84
|
+
new_node2 = new_nodes[1]["self"].split('/').last
|
|
85
|
+
existing_nodes = @neo.get_nodes(new_node1, new_node2)
|
|
86
|
+
expect(existing_nodes).not_to be_nil
|
|
87
|
+
expect(existing_nodes.size).to eq(2)
|
|
88
|
+
existing_nodes[0]["self"] == new_node1["self"]
|
|
89
|
+
existing_nodes[1]["self"] == new_node2["self"]
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "is not super slow?" , :slow => true do
|
|
93
|
+
one_node = @neo.create_nodes( 1)
|
|
94
|
+
ten_nodes = @neo.create_nodes( 10)
|
|
95
|
+
one_hundred_nodes = @neo.create_nodes(100)
|
|
96
|
+
|
|
97
|
+
Benchmark.bm do |x|
|
|
98
|
+
x.report( "get 1 node ") { @neo.get_nodes(one_node) }
|
|
99
|
+
x.report( "get 10 nodes") { @neo.get_nodes(ten_nodes) }
|
|
100
|
+
x.report("get 100 nodes") { @neo.get_nodes(one_hundred_nodes) }
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Neography::Rest do
|
|
4
|
+
before(:each) do
|
|
5
|
+
@neo = Neography::Rest.new
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe "create unique constraint" do
|
|
9
|
+
it "can create a unique constraint" do
|
|
10
|
+
label = "User"
|
|
11
|
+
property = "user_id"
|
|
12
|
+
uc = @neo.create_unique_constraint(label, property)
|
|
13
|
+
expect(uc).not_to be_nil
|
|
14
|
+
expect(uc["label"]).to eq(label)
|
|
15
|
+
expect(uc["property_keys"]).to eq([property])
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe "get a unique constraint" do
|
|
20
|
+
it "can get a unique constraint" do
|
|
21
|
+
label = "User"
|
|
22
|
+
property = "user_id"
|
|
23
|
+
uc = @neo.get_unique_constraint(label, property)
|
|
24
|
+
expect(uc).not_to be_nil
|
|
25
|
+
expect(uc.first["label"]).to eq(label)
|
|
26
|
+
expect(uc.first["property_keys"]).to eq([property])
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "get unique constraints" do
|
|
31
|
+
it "can get unique constraints for a label" do
|
|
32
|
+
label = "User"
|
|
33
|
+
property = "user_id"
|
|
34
|
+
uc = @neo.get_uniqueness(label)
|
|
35
|
+
expect(uc).not_to be_nil
|
|
36
|
+
expect(uc.first["label"]).to eq(label)
|
|
37
|
+
expect(uc.first["property_keys"]).to eq([property])
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
describe "list constraints" do
|
|
42
|
+
it "can get a list of constraints" do
|
|
43
|
+
label = "User"
|
|
44
|
+
property = "user_id"
|
|
45
|
+
cs = @neo.get_constraints
|
|
46
|
+
expect(cs).not_to be_nil
|
|
47
|
+
expect(cs.first["label"]).to eq(label)
|
|
48
|
+
expect(cs.first["property_keys"]).to eq([property])
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "can get a list of constraints for a specifc label" do
|
|
52
|
+
label = "User"
|
|
53
|
+
property = "user_id"
|
|
54
|
+
cs = @neo.get_constraints(label)
|
|
55
|
+
expect(cs).not_to be_nil
|
|
56
|
+
expect(cs.first["label"]).to eq(label)
|
|
57
|
+
expect(cs.first["property_keys"]).to eq([property])
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe "drop a constraint" do
|
|
62
|
+
it "can drop a constraint" do
|
|
63
|
+
label = "User"
|
|
64
|
+
property = "user_id"
|
|
65
|
+
uc = @neo.drop_constraint(label, property)
|
|
66
|
+
expect(uc).to be_nil
|
|
67
|
+
cs = @neo.get_constraints(label)
|
|
68
|
+
expect(cs).to be_empty
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Neography::Rest do
|
|
4
|
+
before(:each) do
|
|
5
|
+
@neo = Neography::Rest.new
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
describe "get_nodes", :slow => true do
|
|
10
|
+
it "can get nodes that exists" do
|
|
11
|
+
existing_nodes = @neo.get_nodes
|
|
12
|
+
expect(existing_nodes).not_to be_nil
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it "can get all nodes that exists the ugly way" do
|
|
16
|
+
new_node = @neo.create_node
|
|
17
|
+
last_node_id = new_node["self"].split('/').last.to_i
|
|
18
|
+
existing_nodes = @neo.get_nodes((1..last_node_id).to_a)
|
|
19
|
+
expect(existing_nodes).not_to be_nil
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Neography::Rest do
|
|
4
|
+
before(:each) do
|
|
5
|
+
@neo = Neography::Rest.new
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe "don't break gremlin" do
|
|
9
|
+
it "can handle node and relationship indexes", :gremlin => true do
|
|
10
|
+
new_node1 = @neo.create_node
|
|
11
|
+
new_node2 = @neo.create_node
|
|
12
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
|
13
|
+
key = generate_text(6)
|
|
14
|
+
value = generate_text
|
|
15
|
+
@neo.add_node_to_index("test_index", key, value, new_node1)
|
|
16
|
+
@neo.add_relationship_to_index("test_index2", key, value, new_relationship)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "gremlin works", :gremlin => true do
|
|
20
|
+
root_node = @neo.execute_script("g.v(0)")
|
|
21
|
+
expect(root_node).to have_key("self")
|
|
22
|
+
expect(root_node["self"].split('/').last).to eq("0")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
describe "break gremlin" do
|
|
28
|
+
it "can can't handle node and relationship indexes with the same name", :gremlin => true do
|
|
29
|
+
new_node1 = @neo.create_node
|
|
30
|
+
new_node2 = @neo.create_node
|
|
31
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
|
32
|
+
key = generate_text(6)
|
|
33
|
+
value = generate_text
|
|
34
|
+
@neo.add_node_to_index("test_index3", key, value, new_node1)
|
|
35
|
+
@neo.add_relationship_to_index("test_index3", key, value, new_relationship)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "gremlin works", :gremlin => true do
|
|
39
|
+
root_node = @neo.execute_script("g.v(0)")
|
|
40
|
+
expect(root_node).to have_key("self")
|
|
41
|
+
expect(root_node["self"].split('/').last).to eq("0")
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Neography::Connection do
|
|
4
|
+
|
|
5
|
+
it "should not add a content-type header if there's no existing headers" do
|
|
6
|
+
expect(subject.merge_options({}).keys).to eq([])
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "should add a content type if there's existing headers" do
|
|
10
|
+
expect(subject.merge_options({:headers => {'Content-Type' => 'foo/bar'}})[:headers]).to eq(
|
|
11
|
+
{'Content-Type' => "foo/bar", "User-Agent" => "Neography/#{Neography::VERSION}" , "X-Stream"=>true, "max-execution-time"=>6000}
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe Neography::Rest do
|
|
4
|
+
before(:each) do
|
|
5
|
+
@neo = Neography::Rest.new
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
describe "list indexes" do
|
|
9
|
+
it "can get a listing of node indexes" do
|
|
10
|
+
new_node = @neo.create_node
|
|
11
|
+
key = generate_text(6)
|
|
12
|
+
value = generate_text
|
|
13
|
+
@neo.add_node_to_index("test_node_index", key, value, new_node)
|
|
14
|
+
expect(@neo.list_indexes).not_to be_nil
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "can get a listing of relationship indexes" do
|
|
18
|
+
new_node1 = @neo.create_node
|
|
19
|
+
new_node2 = @neo.create_node
|
|
20
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
|
21
|
+
key = generate_text(6)
|
|
22
|
+
value = generate_text
|
|
23
|
+
@neo.add_relationship_to_index("test_relationship_index", key, value, new_relationship)
|
|
24
|
+
expect(@neo.list_relationship_indexes).not_to be_nil
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe "create an index" do
|
|
29
|
+
it "can create a node index" do
|
|
30
|
+
name = generate_text(6)
|
|
31
|
+
new_index = @neo.create_node_index(name)
|
|
32
|
+
expect(new_index).not_to be_nil
|
|
33
|
+
expect(new_index["template"]).to eq("#{@neo.configuration}/db/data/index/node/#{name}/{key}/{value}")
|
|
34
|
+
expect(new_index["provider"]).to eq("lucene")
|
|
35
|
+
expect(new_index["type"]).to eq("exact")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it "can create a node index with options" do
|
|
39
|
+
name = generate_text(6)
|
|
40
|
+
new_index = @neo.create_node_index(name, "fulltext","lucene")
|
|
41
|
+
expect(new_index).not_to be_nil
|
|
42
|
+
expect(new_index["template"]).to eq("#{@neo.configuration}/db/data/index/node/#{name}/{key}/{value}")
|
|
43
|
+
expect(new_index["provider"]).to eq("lucene")
|
|
44
|
+
expect(new_index["type"]).to eq("fulltext")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "can create a node index with extra configuration options" do
|
|
48
|
+
name = generate_text(6)
|
|
49
|
+
new_index = @neo.create_node_index(name, "fulltext","lucene", extra: 'extra-value')
|
|
50
|
+
expect(new_index).not_to be_nil
|
|
51
|
+
expect(new_index["template"]).to eq("#{@neo.configuration}/db/data/index/node/#{name}/{key}/{value}")
|
|
52
|
+
expect(new_index["provider"]).to eq("lucene")
|
|
53
|
+
expect(new_index["extra"]).to eq("extra-value")
|
|
54
|
+
expect(new_index["type"]).to eq("fulltext")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it "can create a relationship index" do
|
|
58
|
+
name = generate_text(6)
|
|
59
|
+
new_index = @neo.create_relationship_index(name)
|
|
60
|
+
expect(new_index).not_to be_nil
|
|
61
|
+
expect(new_index["template"]).to eq("#{@neo.configuration}/db/data/index/relationship/#{name}/{key}/{value}")
|
|
62
|
+
expect(new_index["provider"]).to eq("lucene")
|
|
63
|
+
expect(new_index["type"]).to eq("exact")
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "can create a relationship index with options" do
|
|
67
|
+
name = generate_text(6)
|
|
68
|
+
new_index = @neo.create_relationship_index(name, "fulltext","lucene")
|
|
69
|
+
expect(new_index).not_to be_nil
|
|
70
|
+
expect(new_index["template"]).to eq("#{@neo.configuration}/db/data/index/relationship/#{name}/{key}/{value}")
|
|
71
|
+
expect(new_index["provider"]).to eq("lucene")
|
|
72
|
+
expect(new_index["type"]).to eq("fulltext")
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
describe "add to index" do
|
|
79
|
+
it "can add a node to an index" do
|
|
80
|
+
new_node = @neo.create_node
|
|
81
|
+
key = generate_text(6)
|
|
82
|
+
value = generate_text
|
|
83
|
+
@neo.add_node_to_index("test_node_index", key, value, new_node)
|
|
84
|
+
new_index = @neo.get_node_index("test_node_index", key, value)
|
|
85
|
+
expect(new_index).not_to be_nil
|
|
86
|
+
@neo.remove_node_from_index("test_node_index", key, value, new_node)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "can add a relationship to an index" do
|
|
90
|
+
new_node1 = @neo.create_node
|
|
91
|
+
new_node2 = @neo.create_node
|
|
92
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
|
93
|
+
key = generate_text(6)
|
|
94
|
+
value = generate_text
|
|
95
|
+
@neo.add_relationship_to_index("test_relationship_index", key, value, new_relationship)
|
|
96
|
+
new_index = @neo.get_relationship_index("test_relationship_index", key, value)
|
|
97
|
+
expect(new_index).not_to be_nil
|
|
98
|
+
@neo.remove_relationship_from_index("test_relationship_index", key, value, new_relationship)
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
describe "remove from index" do
|
|
103
|
+
it "can remove a node from an index" do
|
|
104
|
+
new_node = @neo.create_node
|
|
105
|
+
key = generate_text(6)
|
|
106
|
+
value = generate_text
|
|
107
|
+
@neo.add_node_to_index("test_node_index", key, value, new_node)
|
|
108
|
+
new_index = @neo.get_node_index("test_node_index", key, value)
|
|
109
|
+
expect(new_index).not_to be_nil
|
|
110
|
+
@neo.remove_node_from_index("test_node_index", key, value, new_node)
|
|
111
|
+
new_index = @neo.get_node_index("test_node_index", key, value)
|
|
112
|
+
expect(new_index).to be_nil
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it "can remove a node from an index without supplying value" do
|
|
116
|
+
new_node = @neo.create_node
|
|
117
|
+
key = generate_text(6)
|
|
118
|
+
value = generate_text
|
|
119
|
+
@neo.add_node_to_index("test_node_index", key, value, new_node)
|
|
120
|
+
new_index = @neo.get_node_index("test_node_index", key, value)
|
|
121
|
+
expect(new_index).not_to be_nil
|
|
122
|
+
@neo.remove_node_from_index("test_node_index", key, new_node)
|
|
123
|
+
new_index = @neo.get_node_index("test_node_index", key, value)
|
|
124
|
+
expect(new_index).to be_nil
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it "can remove a node from an index without supplying key nor value" do
|
|
128
|
+
new_node = @neo.create_node
|
|
129
|
+
key = generate_text(6)
|
|
130
|
+
value = generate_text
|
|
131
|
+
@neo.add_node_to_index("test_node_index", key, value, new_node)
|
|
132
|
+
new_index = @neo.get_node_index("test_node_index", key, value)
|
|
133
|
+
expect(new_index).not_to be_nil
|
|
134
|
+
@neo.remove_node_from_index("test_node_index", new_node)
|
|
135
|
+
new_index = @neo.get_node_index("test_node_index", key, value)
|
|
136
|
+
expect(new_index).to be_nil
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
it "can remove a relationship from an index" do
|
|
140
|
+
new_node1 = @neo.create_node
|
|
141
|
+
new_node2 = @neo.create_node
|
|
142
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
|
143
|
+
key = generate_text(6)
|
|
144
|
+
value = generate_text
|
|
145
|
+
@neo.add_relationship_to_index("test_relationship_index", key, value, new_relationship)
|
|
146
|
+
new_index = @neo.get_relationship_index("test_relationship_index", key, value)
|
|
147
|
+
expect(new_index).not_to be_nil
|
|
148
|
+
@neo.remove_relationship_from_index("test_relationship_index", key, value, new_relationship)
|
|
149
|
+
new_index = @neo.get_relationship_index("test_relationship_index", key, value)
|
|
150
|
+
expect(new_index).to be_nil
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
it "can remove a relationship from an index without supplying value" do
|
|
154
|
+
new_node1 = @neo.create_node
|
|
155
|
+
new_node2 = @neo.create_node
|
|
156
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
|
157
|
+
key = generate_text(6)
|
|
158
|
+
value = generate_text
|
|
159
|
+
@neo.add_relationship_to_index("test_relationship_index", key, value, new_relationship)
|
|
160
|
+
new_index = @neo.get_relationship_index("test_relationship_index", key, value)
|
|
161
|
+
expect(new_index).not_to be_nil
|
|
162
|
+
@neo.remove_relationship_from_index("test_relationship_index", key, new_relationship)
|
|
163
|
+
new_index = @neo.get_relationship_index("test_relationship_index", key, value)
|
|
164
|
+
expect(new_index).to be_nil
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
it "can remove a relationship from an index without supplying key nor value" do
|
|
168
|
+
new_node1 = @neo.create_node
|
|
169
|
+
new_node2 = @neo.create_node
|
|
170
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
|
171
|
+
key = generate_text(6)
|
|
172
|
+
value = generate_text
|
|
173
|
+
@neo.add_relationship_to_index("test_relationship_index", key, value, new_relationship)
|
|
174
|
+
new_index = @neo.get_relationship_index("test_relationship_index", key, value)
|
|
175
|
+
expect(new_index).not_to be_nil
|
|
176
|
+
@neo.remove_relationship_from_index("test_relationship_index", new_relationship)
|
|
177
|
+
new_index = @neo.get_relationship_index("test_relationship_index", key, value)
|
|
178
|
+
expect(new_index).to be_nil
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
it "throws an error when there is an empty string in the value when removing a node" do
|
|
182
|
+
new_node = @neo.create_node
|
|
183
|
+
key = generate_text(6)
|
|
184
|
+
value = generate_text
|
|
185
|
+
@neo.add_node_to_index("test_node_index", key, value, new_node)
|
|
186
|
+
new_index = @neo.get_node_index("test_node_index", key, value)
|
|
187
|
+
expect(new_index).not_to be_nil
|
|
188
|
+
expect { @neo.remove_node_from_index("test_node_index", key, "", new_node) }.to raise_error Neography::NeographyError
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
describe "get index" do
|
|
193
|
+
it "can get a node index" do
|
|
194
|
+
new_node = @neo.create_node
|
|
195
|
+
key = generate_text(6)
|
|
196
|
+
value = generate_text
|
|
197
|
+
@neo.add_node_to_index("test_node_index", key, value, new_node)
|
|
198
|
+
new_index = @neo.get_node_index("test_node_index", key, value)
|
|
199
|
+
expect(new_index).not_to be_nil
|
|
200
|
+
@neo.remove_node_from_index("test_node_index", key, value, new_node)
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
it "can get a node index with a space in the value" do
|
|
204
|
+
new_node = @neo.create_node
|
|
205
|
+
key = generate_text(6)
|
|
206
|
+
value = generate_text + " " + generate_text
|
|
207
|
+
@neo.add_node_to_index("test_node_index", key, value, new_node)
|
|
208
|
+
new_index = @neo.get_node_index("test_node_index", key, value)
|
|
209
|
+
expect(new_index).not_to be_nil
|
|
210
|
+
@neo.remove_node_from_index("test_node_index", key, value, new_node)
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
it "can get a node index with a slash in the value" do
|
|
214
|
+
new_node = @neo.create_node
|
|
215
|
+
key = generate_text(6)
|
|
216
|
+
value = generate_text + "/" + generate_text
|
|
217
|
+
@neo.add_node_to_index("test_node_index", key, value, new_node)
|
|
218
|
+
new_index = @neo.get_node_index("test_node_index", key, value)
|
|
219
|
+
expect(new_index).not_to be_nil
|
|
220
|
+
@neo.remove_node_from_index("test_node_index", key, value, new_node)
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
it "can get a relationship index" do
|
|
224
|
+
new_node1 = @neo.create_node
|
|
225
|
+
new_node2 = @neo.create_node
|
|
226
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
|
227
|
+
key = generate_text(6)
|
|
228
|
+
value = generate_text
|
|
229
|
+
@neo.add_relationship_to_index("test_relationship_index", key, value, new_relationship)
|
|
230
|
+
new_index = @neo.get_relationship_index("test_relationship_index", key, value)
|
|
231
|
+
expect(new_index).not_to be_nil
|
|
232
|
+
@neo.remove_relationship_from_index("test_relationship_index", key, value, new_relationship)
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
describe "query index" do
|
|
237
|
+
it "can query a node index" do
|
|
238
|
+
new_node = @neo.create_node
|
|
239
|
+
key = generate_text(6)
|
|
240
|
+
value = generate_text
|
|
241
|
+
@neo.add_node_to_index("test_node_index", key, value, new_node)
|
|
242
|
+
new_index = @neo.get_node_index("test_node_index", key, value)
|
|
243
|
+
expect(new_index.first["self"]).to eq(new_node["self"])
|
|
244
|
+
@neo.remove_node_from_index("test_node_index", key, value, new_node)
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
it "can find a node index" do
|
|
248
|
+
new_node = @neo.create_node
|
|
249
|
+
key = generate_text(6)
|
|
250
|
+
value = generate_text
|
|
251
|
+
@neo.add_node_to_index("test_node_index", key, value, new_node)
|
|
252
|
+
new_index = @neo.find_node_index("test_node_index", key, value)
|
|
253
|
+
expect(new_index.first["self"]).to eq(new_node["self"])
|
|
254
|
+
@neo.remove_node_from_index("test_node_index", key, value, new_node)
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
it "can find a node index using generic query" do
|
|
258
|
+
new_node = @neo.create_node
|
|
259
|
+
key = generate_text(6)
|
|
260
|
+
value = generate_text
|
|
261
|
+
@neo.add_node_to_index("test_node_index", key, value, new_node)
|
|
262
|
+
new_index = @neo.find_node_index("test_node_index", "#{key}: #{value}")
|
|
263
|
+
expect(new_index.first["self"]).to eq(new_node["self"])
|
|
264
|
+
@neo.remove_node_from_index("test_node_index", key, value, new_node)
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
it "can find a node index with spaces in the value" do
|
|
268
|
+
new_node = @neo.create_node
|
|
269
|
+
key = generate_text(6)
|
|
270
|
+
value = generate_text + ' ' + generate_text
|
|
271
|
+
@neo.add_node_to_index("test_node_index", key, value, new_node)
|
|
272
|
+
new_index = @neo.find_node_index("test_node_index", key, value)
|
|
273
|
+
expect(new_index).not_to be_nil
|
|
274
|
+
expect(new_index.first["self"]).to eq(new_node["self"])
|
|
275
|
+
@neo.remove_node_from_index("test_node_index", key, value, new_node)
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
it "can find a node index with slashes in the value" do
|
|
279
|
+
new_node = @neo.create_node
|
|
280
|
+
key = generate_text(6)
|
|
281
|
+
value = generate_text + '/' + generate_text
|
|
282
|
+
@neo.add_node_to_index("test_node_index", key, value, new_node)
|
|
283
|
+
new_index = @neo.find_node_index("test_node_index", key, value)
|
|
284
|
+
expect(new_index).not_to be_nil
|
|
285
|
+
expect(new_index.first["self"]).to eq(new_node["self"])
|
|
286
|
+
@neo.remove_node_from_index("test_node_index", key, value, new_node)
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
it "can get a relationship index" do
|
|
290
|
+
new_node1 = @neo.create_node
|
|
291
|
+
new_node2 = @neo.create_node
|
|
292
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
|
293
|
+
key = generate_text(6)
|
|
294
|
+
value = generate_text
|
|
295
|
+
@neo.add_relationship_to_index("test_relationship_index", key, value, new_relationship)
|
|
296
|
+
new_index = @neo.get_relationship_index("test_relationship_index", key, value)
|
|
297
|
+
expect(new_index.first["self"]).to eq(new_relationship["self"])
|
|
298
|
+
@neo.remove_relationship_from_index("test_relationship_index", key, value, new_relationship)
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
it "can get a relationship index with empty spaces" do
|
|
302
|
+
new_node1 = @neo.create_node
|
|
303
|
+
new_node2 = @neo.create_node
|
|
304
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
|
305
|
+
key = generate_text(6)
|
|
306
|
+
value = generate_text + " " + generate_text
|
|
307
|
+
@neo.add_relationship_to_index("test_relationship_index", key, value, new_relationship)
|
|
308
|
+
new_index = @neo.get_relationship_index("test_relationship_index", key, value)
|
|
309
|
+
expect(new_index.first["self"]).to eq(new_relationship["self"])
|
|
310
|
+
@neo.remove_relationship_from_index("test_relationship_index", key, value, new_relationship)
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
it "can find a relationship index" do
|
|
314
|
+
new_node1 = @neo.create_node
|
|
315
|
+
new_node2 = @neo.create_node
|
|
316
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
|
317
|
+
key = generate_text(6)
|
|
318
|
+
value = generate_text
|
|
319
|
+
@neo.add_relationship_to_index("test_relationship_index", key, value, new_relationship)
|
|
320
|
+
new_index = @neo.find_relationship_index("test_relationship_index", key, value)
|
|
321
|
+
expect(new_index.first["self"]).to eq(new_relationship["self"])
|
|
322
|
+
@neo.remove_relationship_from_index("test_relationship_index", key, value, new_relationship)
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
it "can find a relationship index using generic query" do
|
|
326
|
+
new_node1 = @neo.create_node
|
|
327
|
+
new_node2 = @neo.create_node
|
|
328
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
|
329
|
+
key = generate_text(6)
|
|
330
|
+
value = generate_text
|
|
331
|
+
@neo.add_relationship_to_index("test_relationship_index", key, value, new_relationship)
|
|
332
|
+
new_index = @neo.find_relationship_index("test_relationship_index", "#{key}: #{value}")
|
|
333
|
+
expect(new_index.first["self"]).to eq(new_relationship["self"])
|
|
334
|
+
@neo.remove_relationship_from_index("test_relationship_index", key, value, new_relationship)
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
it "can find use the results of a node index" do
|
|
338
|
+
new_node1 = @neo.create_node
|
|
339
|
+
new_node2 = @neo.create_node
|
|
340
|
+
key = generate_text(6)
|
|
341
|
+
value1 = generate_text
|
|
342
|
+
value2 = generate_text
|
|
343
|
+
@neo.add_node_to_index("test_node_index", key, value1, new_node1)
|
|
344
|
+
@neo.add_node_to_index("test_node_index", key, value2, new_node2)
|
|
345
|
+
existing_node1 = @neo.get_node_index("test_node_index", key, value1)
|
|
346
|
+
existing_node2 = @neo.get_node_index("test_node_index", key, value2)
|
|
347
|
+
new_relationship = @neo.create_relationship("friends", existing_node1, existing_node2)
|
|
348
|
+
expect(new_relationship["start"]).not_to be_nil
|
|
349
|
+
expect(new_relationship["start"]).to eq(new_node1["self"])
|
|
350
|
+
expect(new_relationship["end"]).not_to be_nil
|
|
351
|
+
expect(new_relationship["end"]).to eq(new_node2["self"])
|
|
352
|
+
@neo.remove_node_from_index("test_node_index", new_node1)
|
|
353
|
+
@neo.remove_node_from_index("test_node_index", new_node2)
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
describe "auto indexes" do
|
|
359
|
+
|
|
360
|
+
it "can check the status of node auto index" do
|
|
361
|
+
expect(@neo.get_node_auto_index_status).to satisfy{|status| [true, false].include?(status)}
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
it "can check the status of relationship auto index" do
|
|
365
|
+
expect(@neo.get_relationship_auto_index_status).to satisfy{|status| [true, false].include?(status)}
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
it "can change the node auto index status" do
|
|
369
|
+
@neo.set_node_auto_index_status(true)
|
|
370
|
+
expect(@neo.get_node_auto_index_status).to be true
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
it "can change the relationship auto index status" do
|
|
374
|
+
@neo.set_relationship_auto_index_status(true)
|
|
375
|
+
expect(@neo.get_relationship_auto_index_status).to be true
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
it "can get a list of auto indexed node properties" do
|
|
379
|
+
@neo.set_node_auto_index_status(true)
|
|
380
|
+
@neo.create_node_auto_index
|
|
381
|
+
@neo.add_node_auto_index_property("name")
|
|
382
|
+
expect(@neo.get_node_auto_index_properties).to eq(["name"])
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
it "can get a list of auto indexed relationship properties" do
|
|
386
|
+
@neo.set_relationship_auto_index_status(true)
|
|
387
|
+
@neo.create_relationship_auto_index
|
|
388
|
+
@neo.add_relationship_auto_index_property("weight")
|
|
389
|
+
expect(@neo.get_relationship_auto_index_properties).to eq(["weight"])
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
it "can remove a property from the auto indexed node properties" do
|
|
393
|
+
@neo.add_node_auto_index_property("name")
|
|
394
|
+
@neo.add_node_auto_index_property("label")
|
|
395
|
+
expect(@neo.get_node_auto_index_properties).to eq(["name", "label"])
|
|
396
|
+
@neo.remove_node_auto_index_property("label")
|
|
397
|
+
expect(@neo.get_node_auto_index_properties).to eq(["name"])
|
|
398
|
+
end
|
|
399
|
+
|
|
400
|
+
it "can remove a property from the auto indexed relationship properties" do
|
|
401
|
+
@neo.add_relationship_auto_index_property("weight")
|
|
402
|
+
@neo.add_relationship_auto_index_property("strength")
|
|
403
|
+
expect(@neo.get_relationship_auto_index_properties).to match_array(["weight", "strength"])
|
|
404
|
+
@neo.remove_relationship_auto_index_property("strength")
|
|
405
|
+
expect(@neo.get_relationship_auto_index_properties).to eq(["weight"])
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
it "can get a node from an automatic index" do
|
|
409
|
+
new_node = @neo.create_node("name" => "Max")
|
|
410
|
+
existing_nodes = @neo.get_node_auto_index("name", "Max")
|
|
411
|
+
expect(existing_nodes.collect{|n| n["self"]}.include?(new_node["self"])).to be true
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
it "can query a node from an automatic index using key value" do
|
|
415
|
+
new_node = @neo.create_node("name" => "Max")
|
|
416
|
+
existing_nodes = @neo.find_node_auto_index("name", "Max")
|
|
417
|
+
expect(existing_nodes.collect{|n| n["self"]}.include?(new_node["self"])).to be true
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
it "can query a node from an automatic index" do
|
|
421
|
+
new_node = @neo.create_node("name" => "Max")
|
|
422
|
+
existing_nodes = @neo.find_node_auto_index("name:Max")
|
|
423
|
+
expect(existing_nodes.collect{|n| n["self"]}.include?(new_node["self"])).to be true
|
|
424
|
+
# check that more complex queries are correctly handled
|
|
425
|
+
existing_nodes = @neo.find_node_auto_index("name:Max OR name:Max")
|
|
426
|
+
expect(existing_nodes.collect{|n| n["self"]}.include?(new_node["self"])).to be true
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
it "can get a relationship from an automatic index" do
|
|
430
|
+
new_node1 = @neo.create_node("name" => "Max")
|
|
431
|
+
new_node2 = @neo.create_node("name" => "Peter")
|
|
432
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"weight" => 5})
|
|
433
|
+
existing_rels = @neo.get_relationship_auto_index("weight", 5)
|
|
434
|
+
expect(existing_rels.collect{|n| n["self"]}.include?(new_relationship["self"])).to be true
|
|
435
|
+
end
|
|
436
|
+
|
|
437
|
+
it "can query a relationship from an automatic index using key value" do
|
|
438
|
+
new_node1 = @neo.create_node("name" => "Max")
|
|
439
|
+
new_node2 = @neo.create_node("name" => "Peter")
|
|
440
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"weight" => 5})
|
|
441
|
+
existing_rels = @neo.find_relationship_auto_index("weight", 5)
|
|
442
|
+
expect(existing_rels.collect{|n| n["self"]}.include?(new_relationship["self"])).to be true
|
|
443
|
+
end
|
|
444
|
+
|
|
445
|
+
it "can query a relationship from an automatic index" do
|
|
446
|
+
new_node1 = @neo.create_node("name" => "Max")
|
|
447
|
+
new_node2 = @neo.create_node("name" => "Peter")
|
|
448
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2, {"weight" => 5})
|
|
449
|
+
existing_rels = @neo.find_relationship_auto_index("weight:5")
|
|
450
|
+
expect(existing_rels.collect{|n| n["self"]}.include?(new_relationship["self"])).to be true
|
|
451
|
+
end
|
|
452
|
+
|
|
453
|
+
end
|
|
454
|
+
|
|
455
|
+
describe "drop index" do
|
|
456
|
+
it "can drop a node index" do
|
|
457
|
+
new_node = @neo.create_node
|
|
458
|
+
key = generate_text(6)
|
|
459
|
+
value = generate_text
|
|
460
|
+
@neo.add_node_to_index("test_node_index", key, value, new_node)
|
|
461
|
+
new_index = @neo.get_node_index("test_node_index", key, value)
|
|
462
|
+
expect(new_index).not_to be_nil
|
|
463
|
+
@neo.drop_node_index("test_node_index")
|
|
464
|
+
expect { @neo.get_node_index("test_node_index", key, value) }.to raise_error Neography::NotFoundException
|
|
465
|
+
end
|
|
466
|
+
|
|
467
|
+
it "can get a relationship index" do
|
|
468
|
+
new_node1 = @neo.create_node
|
|
469
|
+
new_node2 = @neo.create_node
|
|
470
|
+
new_relationship = @neo.create_relationship("friends", new_node1, new_node2)
|
|
471
|
+
key = generate_text(6)
|
|
472
|
+
value = generate_text
|
|
473
|
+
@neo.add_relationship_to_index("test_relationship_index", key, value, new_relationship)
|
|
474
|
+
new_index = @neo.get_relationship_index("test_relationship_index", key, value)
|
|
475
|
+
expect(new_index).not_to be_nil
|
|
476
|
+
@neo.drop_relationship_index("test_relationship_index")
|
|
477
|
+
expect { @neo.get_relationship_index("test_relationship_index", key, value) }.to raise_error Neography::NotFoundException
|
|
478
|
+
end
|
|
479
|
+
end
|
|
480
|
+
|
|
481
|
+
end
|