neo4j-core 0.0.15-java → 2.0.0.alpha.1-java
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -2
- data/README.rdoc +12 -192
- data/lib/neo4j-core.rb +3 -19
- data/lib/neo4j-core/database.rb +5 -4
- data/lib/neo4j-core/event_handler.rb +1 -1
- data/lib/neo4j-core/index/class_methods.rb +41 -27
- data/lib/neo4j-core/index/index.rb +4 -3
- data/lib/neo4j-core/index/index_config.rb +23 -30
- data/lib/neo4j-core/index/indexer.rb +53 -65
- data/lib/neo4j-core/index/indexer_registry.rb +2 -2
- data/lib/neo4j-core/index/lucene_query.rb +42 -53
- data/lib/neo4j-core/node/class_methods.rb +4 -4
- data/lib/neo4j-core/node/node.rb +8 -1
- data/lib/neo4j-core/property/property.rb +3 -1
- data/lib/neo4j-core/relationship/relationship.rb +10 -8
- data/lib/neo4j-core/rels/rels.rb +4 -9
- data/lib/neo4j-core/rels/traverser.rb +27 -13
- data/lib/neo4j-core/traversal/prune_evaluator.rb +2 -2
- data/lib/neo4j-core/traversal/traverser.rb +27 -122
- data/lib/neo4j-core/type_converters/type_converters.rb +287 -0
- data/lib/neo4j-core/version.rb +1 -1
- data/lib/neo4j-core/version.rb~ +3 -0
- data/lib/neo4j/config.rb +6 -3
- data/lib/neo4j/neo4j.rb +22 -51
- data/lib/neo4j/node.rb +0 -27
- data/lib/neo4j/relationship.rb +0 -25
- data/lib/test.rb +27 -0
- data/neo4j-core.gemspec +2 -2
- metadata +11 -17
- data/lib/neo4j-core/cypher/cypher.rb +0 -969
- data/lib/neo4j-core/cypher/result_wrapper.rb +0 -48
- data/lib/neo4j-core/hash_with_indifferent_access.rb +0 -165
- data/lib/neo4j-core/index/unique_factory.rb +0 -54
- data/lib/neo4j-core/property/java.rb +0 -59
- data/lib/neo4j-core/wrapper/class_methods.rb +0 -22
- data/lib/neo4j-core/wrapper/wrapper.rb +0 -20
- data/lib/neo4j/algo.rb +0 -300
- data/lib/neo4j/cypher.rb +0 -180
data/Gemfile
CHANGED
@@ -2,8 +2,8 @@ source :gemcutter
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
gem 'neo4j-advanced', "1.
|
6
|
-
gem 'neo4j-enterprise', "1.
|
5
|
+
gem 'neo4j-advanced', "1.6.1.alpha.1", :require => false
|
6
|
+
gem 'neo4j-enterprise', "1.6.1.alpha.1", :require => false
|
7
7
|
|
8
8
|
group 'development' do
|
9
9
|
gem 'guard'
|
data/README.rdoc
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
== Neo4j-core {<img src="https://secure.travis-ci.org/andreasronge/neo4j-core.png" />}[http://travis-ci.org/andreasronge/neo4j-core]
|
2
|
-
|
3
1
|
This gem only contains the JRuby mapping of the Neo4j graph database.
|
4
|
-
The neo4j.rb gem will be split up into
|
5
|
-
This gem will be included by neo4j 2.0.0 gem.
|
6
|
-
|
7
|
-
This gem contains two modules: Neo4j and Neo4j::Core
|
8
|
-
The Neo4j module is public and the Neo4j::Core(::*) are internal modules.
|
2
|
+
The neo4j.rb gem will be split up into two gems, neo4j-core and neo4j.
|
3
|
+
This gem will be included by neo4j 2.0.0 gem (if successful).
|
9
4
|
|
10
|
-
|
5
|
+
Changes from the neo4j.rb
|
6
|
+
* Use of YARD instead of RDoc
|
7
|
+
* Some tidy up of the API and code (e.g. Neo4j::Node#rels methods)
|
8
|
+
* Change of Ruby module structure.
|
9
|
+
* More RSpecs and more use of mocking combined with real testing of the Java layer
|
10
|
+
* Make sure that we retrieve relationships and nodes lazy if possible.
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
This gem contains two modules: Neo4j and Neo4j::Core
|
13
|
+
The Neo4j modules are public and the Neo4j::Core(::*) are private modules
|
14
14
|
|
15
15
|
== The public API
|
16
16
|
|
@@ -20,186 +20,6 @@ The Neo4j module is public and the Neo4j::Core(::*) are internal modules.
|
|
20
20
|
|
21
21
|
{Neo4j} The Database
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
{Neo4j::Algo} Included algorithms, like shortest path
|
26
|
-
|
27
|
-
== Custom Index
|
28
|
-
|
29
|
-
You can create your own indexer.
|
30
|
-
|
31
|
-
class MyIndex
|
32
|
-
extend Neo4j::Core::Index::ClassMethods
|
33
|
-
include Neo4j::Core::Index
|
34
|
-
|
35
|
-
node_indexer do
|
36
|
-
index_names :exact => 'myindex_exact', :fulltext => 'myindex_fulltext'
|
37
|
-
trigger_on :myindex => true, :things => ['a', 'b']
|
38
|
-
end
|
39
|
-
|
40
|
-
index :name
|
41
|
-
end
|
42
|
-
|
43
|
-
All nodes with the property <tt>myindex == true</tt> or property <tt>things</tt> <tt>'a'</tt> or <tt>'b'</tt>
|
44
|
-
will be indexed using this index.
|
45
|
-
|
46
|
-
Exampel:
|
47
|
-
n = Neo4j::Node.new(:myindex = true, :name => 'foo')
|
48
|
-
MyIndex.find('name: foo').first #=> n
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
== Cypher
|
53
|
-
|
54
|
-
Example:
|
55
|
-
Neo4j.query { node(3) }
|
56
|
-
|
57
|
-
Example with parameters:
|
58
|
-
Neo4j.query(Neo4j.ref_node} do |ref|
|
59
|
-
ref <=> :x
|
60
|
-
:x
|
61
|
-
end
|
62
|
-
|
63
|
-
Notice
|
64
|
-
* The last statement in the expression will be the return value.
|
65
|
-
* You can skip the start, match, where and ret (they are just empty methods).
|
66
|
-
|
67
|
-
=== Cypher Examples
|
68
|
-
|
69
|
-
"START n0=node(3) RETURN n0"
|
70
|
-
Neo4j.query do
|
71
|
-
start n = node(3)
|
72
|
-
ret n
|
73
|
-
end
|
74
|
-
# the above is same as:
|
75
|
-
Neo4j.query { node(3) }
|
76
|
-
|
77
|
-
"START n0=node(42) RETURN n0"
|
78
|
-
node(Neo4j::Node.new)
|
79
|
-
|
80
|
-
"START r0=relationship(3,4) RETURN r0"
|
81
|
-
rel(3,4)
|
82
|
-
|
83
|
-
"START n0=node(3) MATCH (n0)--(x) RETURN x"
|
84
|
-
start n = node(3)
|
85
|
-
match n <=> :x
|
86
|
-
ret :x
|
87
|
-
|
88
|
-
"START n0=node(3) MATCH (n0)--(v0) RETURN v0"
|
89
|
-
x = node
|
90
|
-
n = node(3)
|
91
|
-
match n <=> x
|
92
|
-
ret x
|
93
|
-
|
94
|
-
"START n0=node(3) MATCH (n0)--(v0) RETURN v0.name"
|
95
|
-
x = node
|
96
|
-
n = node(3)
|
97
|
-
match n <=> x
|
98
|
-
ret x[:name]
|
99
|
-
|
100
|
-
"START n0=node(1) RETURN n0.name AS SomethingTotallyDifferent"
|
101
|
-
x = node(1)
|
102
|
-
x[:name].as('SomethingTotallyDifferent')
|
103
|
-
|
104
|
-
"START n0=node:fooindex_exact(name:A) RETURN n0"
|
105
|
-
query(FooIndex, "name:A")
|
106
|
-
|
107
|
-
"START n0=node:fooindex_fulltext(desc="A") RETURN n0"
|
108
|
-
lookup(FooIndex, "desc", "A")
|
109
|
-
|
110
|
-
"START n0=node(1),n1=node(2) RETURN n0,n1"
|
111
|
-
[node(1), node(2)]
|
112
|
-
|
113
|
-
"START n0=node(3) MATCH (n0)-->(c)-->(d) RETURN c"
|
114
|
-
node(3) >> node(:c) >> :d
|
115
|
-
:c
|
116
|
-
|
117
|
-
"START n0=node(3) MATCH (n0)-[r]->(x) RETURN r"
|
118
|
-
node(3) > :r > :x
|
119
|
-
:r
|
120
|
-
|
121
|
-
"START n0=node(3) MATCH (n0)-[r:friends]->(x) RETURN r"
|
122
|
-
r = rel('r:friends').as(:r)
|
123
|
-
node(3) > r > :x
|
124
|
-
r
|
125
|
-
|
126
|
-
"START n0=node(3,1) WHERE n0.age < 30 RETURN n0"
|
127
|
-
n=node(3, 1)
|
128
|
-
where n[:age] < 30
|
129
|
-
ret n
|
130
|
-
|
131
|
-
"START n0=node(3,4) WHERE n0.desc = "hej" RETURN n0"
|
132
|
-
n=node(3, 4)
|
133
|
-
n[:desc] == "hej"
|
134
|
-
n
|
135
|
-
|
136
|
-
"START n0=node(3) MATCH (n0)<-[:knows]-(c) RETURN c"
|
137
|
-
a=node(3)
|
138
|
-
a < ':knows' < :c
|
139
|
-
:c
|
140
|
-
|
141
|
-
"START n0=node(3) MATCH (n0)-[r]->(v1) WHERE type(r) =~ /K.*/ RETURN r"
|
142
|
-
n=node(3)
|
143
|
-
n > (r=rel('r')) > node
|
144
|
-
r.rel_type =~ /K.*/
|
145
|
-
r
|
146
|
-
|
147
|
-
"START n0=node(3) MATCH m2 = (n0)-->(b) RETURN b,length(m2)"
|
148
|
-
p = node(3) >> :b; [:b, p.length]
|
149
|
-
|
150
|
-
"START n0=node(1) MATCH (n0)-->(b) RETURN distinct n0"
|
151
|
-
n=node(1); n>>:b; n.distinct
|
152
|
-
|
153
|
-
"START n0=node(2) MATCH (n0)-->(x) RETURN n0,count(*)"
|
154
|
-
n = node(2))>>:x
|
155
|
-
[n, count]
|
156
|
-
|
157
|
-
"START n0=node(2,3,4) RETURN sum(n0.property)"
|
158
|
-
n=node(2, 3, 4)
|
159
|
-
n[:property].sum
|
160
|
-
|
161
|
-
"START n0=node(2) MATCH (n0)-->(b) RETURN count(distinct n0.eyes)"
|
162
|
-
n=node(2); n>>:b
|
163
|
-
n[:eyes].distinct.count
|
164
|
-
|
165
|
-
"START n0=node(3,4,5) RETURN ID(n0)"
|
166
|
-
node(3, 4, 5).neo_id
|
167
|
-
|
168
|
-
"START n0=node(2) WHERE any(x in n0.array WHERE x = "one") RETURN n0"
|
169
|
-
a = node(2)
|
170
|
-
a[:array].any? { |x| x == 'one' }
|
171
|
-
a
|
172
|
-
|
173
|
-
"START n0=node(3),n1=node(4),n2=node(1) MATCH m4 = (n0)-->(n1)-->(n2) RETURN extract(x in nodes(m4) : x.age)"
|
174
|
-
a=node(3)
|
175
|
-
b=node(4)
|
176
|
-
c=node(1)
|
177
|
-
p=a>>b>>c
|
178
|
-
p.nodes.extract { |x| x[:age] }
|
179
|
-
|
180
|
-
"START n0=node(3) WHERE abs(n0.x) = 3 RETURN n0"
|
181
|
-
a=node(3); a[:x].abs==3
|
182
|
-
a
|
183
|
-
|
184
|
-
"START n0=node(3,4,5,1,2) RETURN n0 ORDER BY n0.name SKIP 1 LIMIT 2"
|
185
|
-
a=node(3,4,5,1,2); ret(a).asc(a[:name]).skip(1).limit(2)
|
186
|
-
# o same as
|
187
|
-
a=node(3,4,5,1,2); ret a, :asc => a[:name], :skip => 1, :limit => 2
|
188
|
-
|
189
|
-
For more examples, see the RSpecs
|
190
|
-
|
191
|
-
== Creates Your Own Wrapper
|
192
|
-
|
193
|
-
Todo, see {Neo4j::Core::Wrapper}
|
194
|
-
|
195
|
-
|
196
|
-
== Changes
|
197
|
-
|
198
|
-
Changes from the neo4j.rb
|
199
|
-
* Use of YARD instead of RDoc
|
200
|
-
* Some tidy up of the API and code (e.g. Neo4j::Node#rels methods)
|
201
|
-
* Change of Ruby module structure.
|
202
|
-
* More RSpecs and more use of mocking combined with real testing of the Java layer
|
203
|
-
* Make sure that we retrieve relationships and nodes lazy if possible.
|
204
|
-
* Cypher Query DSL
|
23
|
+
== Not Impemented Yet
|
205
24
|
|
25
|
+
Neo4j::Node#outgoing, #incoming, #both methods
|
data/lib/neo4j-core.rb
CHANGED
@@ -1,11 +1,4 @@
|
|
1
1
|
require 'java'
|
2
|
-
include Java
|
3
|
-
|
4
|
-
module Neo4j
|
5
|
-
# Enumerator has been moved to top level in Ruby 1.9.2, make it compatible with Ruby 1.8.7
|
6
|
-
Enumerator = Enumerable::Enumerator unless defined? Enumerator
|
7
|
-
end
|
8
|
-
|
9
2
|
require 'neo4j/config'
|
10
3
|
|
11
4
|
require 'neo4j-community'
|
@@ -19,7 +12,6 @@ require 'neo4j-core/database'
|
|
19
12
|
require 'neo4j-core/to_java'
|
20
13
|
|
21
14
|
require 'neo4j-core/property/property'
|
22
|
-
require 'neo4j-core/property/java'
|
23
15
|
|
24
16
|
require 'neo4j-core/rels/rels'
|
25
17
|
require 'neo4j-core/rels/traverser'
|
@@ -37,13 +29,9 @@ require 'neo4j-core/index/indexer_registry'
|
|
37
29
|
require 'neo4j-core/index/index_config'
|
38
30
|
require 'neo4j-core/index/indexer'
|
39
31
|
require 'neo4j-core/index/lucene_query'
|
40
|
-
require 'neo4j-core/index/unique_factory'
|
41
32
|
|
42
33
|
require 'neo4j-core/equal/equal'
|
43
34
|
|
44
|
-
require 'neo4j-core/wrapper/class_methods'
|
45
|
-
require 'neo4j-core/wrapper/wrapper'
|
46
|
-
|
47
35
|
require 'neo4j-core/relationship/relationship'
|
48
36
|
require 'neo4j-core/relationship/class_methods'
|
49
37
|
|
@@ -52,6 +40,8 @@ require 'neo4j-core/node/class_methods'
|
|
52
40
|
|
53
41
|
require 'neo4j/transaction'
|
54
42
|
|
43
|
+
require 'neo4j-core/type_converters/type_converters'
|
44
|
+
|
55
45
|
require 'neo4j-core/traversal/evaluator'
|
56
46
|
require 'neo4j-core/traversal/filter_predicate'
|
57
47
|
require 'neo4j-core/traversal/prune_evaluator'
|
@@ -59,11 +49,5 @@ require 'neo4j-core/traversal/rel_expander'
|
|
59
49
|
require 'neo4j-core/traversal/traversal'
|
60
50
|
require 'neo4j-core/traversal/traverser'
|
61
51
|
|
62
|
-
require 'neo4j-core/cypher/cypher'
|
63
|
-
require 'neo4j-core/cypher/result_wrapper'
|
64
|
-
require 'neo4j-core/hash_with_indifferent_access'
|
65
|
-
|
66
|
-
require 'neo4j/algo'
|
67
|
-
require 'neo4j/cypher'
|
68
52
|
require 'neo4j/node'
|
69
|
-
require 'neo4j/relationship'
|
53
|
+
require 'neo4j/relationship'
|
data/lib/neo4j-core/database.rb
CHANGED
@@ -53,10 +53,10 @@ module Neo4j
|
|
53
53
|
start_readonly_graph_db
|
54
54
|
elsif Neo4j::Config['ha.db']
|
55
55
|
start_ha_graph_db
|
56
|
-
Neo4j.migrate!
|
56
|
+
Neo4j.migrate!
|
57
57
|
else
|
58
58
|
start_local_graph_db
|
59
|
-
Neo4j.migrate!
|
59
|
+
Neo4j.migrate!
|
60
60
|
end
|
61
61
|
rescue
|
62
62
|
@running = false
|
@@ -67,8 +67,7 @@ module Neo4j
|
|
67
67
|
end
|
68
68
|
|
69
69
|
|
70
|
-
|
71
|
-
def running?
|
70
|
+
def running? #:nodoc:
|
72
71
|
@running
|
73
72
|
end
|
74
73
|
|
@@ -164,6 +163,8 @@ module Neo4j
|
|
164
163
|
Neo4j.logger.info "starting Neo4j in HA mode, machine id: #{Neo4j.config['ha.server_id']} at #{Neo4j.config['ha.server']} db #{@storage_path}"
|
165
164
|
# Modify the public base classes for the HA Node and Relationships
|
166
165
|
# (instead of private Java::OrgNeo4jKernel::HighlyAvailableGraphDatabase::LookupNode)
|
166
|
+
Neo4j::Node.extend_java_class(Java::OrgNeo4jToolingWrap::WrappedNode)
|
167
|
+
Neo4j::Relationship.extend_java_class(Java::OrgNeo4jToolingWrap::WrappedRelationship)
|
167
168
|
@graph = Java::OrgNeo4jKernel::HighlyAvailableGraphDatabase.new(@storage_path, Neo4j.config.to_java_map)
|
168
169
|
@graph.register_transaction_event_handler(@event_handler)
|
169
170
|
@lucene = @graph.index
|
@@ -88,7 +88,7 @@ module Neo4j
|
|
88
88
|
# You only need to implement the methods that you need.
|
89
89
|
#
|
90
90
|
class EventHandler
|
91
|
-
include
|
91
|
+
include org.neo4j.graphdb.event.TransactionEventHandler
|
92
92
|
|
93
93
|
def initialize
|
94
94
|
@listeners = []
|
@@ -7,6 +7,7 @@ module Neo4j
|
|
7
7
|
attr_reader :_indexer
|
8
8
|
|
9
9
|
|
10
|
+
# TODO fix YARD docs update using DSL
|
10
11
|
# Sets which indexer should be used for the given node class.
|
11
12
|
# You can share an indexer between several different classes.
|
12
13
|
#
|
@@ -19,18 +20,49 @@ module Neo4j
|
|
19
20
|
# node_indexer do
|
20
21
|
# index_names :exact => 'myindex_exact', :fulltext => 'myindex_fulltext'
|
21
22
|
# trigger_on :ntype => 'foo', :name => ['bar', 'foobar']
|
22
|
-
#
|
23
|
+
# # TODO multitenancy support
|
23
24
|
# prefix_index_name do
|
24
|
-
# "
|
25
|
+
# return "" unless Neo4j.running?
|
26
|
+
# return "" unless @indexer_for.respond_to?(:ref_node_for_class)
|
27
|
+
# ref_node = @indexer_for.ref_node_for_class.wrapper
|
28
|
+
# prefix = ref_node.send(:_index_prefix) if ref_node.respond_to?(:_index_prefix)
|
29
|
+
# prefix ||= ref_node[:name] # To maintain backward compatiblity
|
30
|
+
# prefix.blank? ? "" : prefix + "_"
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
#
|
34
|
+
# TODO ...
|
35
|
+
# numeric do
|
36
|
+
# type = decl_props && decl_props[field.to_sym] && decl_props[field.to_sym][:type]
|
37
|
+
# type && !type.is_a?(String)
|
25
38
|
# end
|
26
39
|
# end
|
27
40
|
# end
|
28
41
|
#
|
29
|
-
# @
|
42
|
+
# @example Using Neo4j::NodeMixin
|
43
|
+
#
|
44
|
+
# class Contact
|
45
|
+
# include Neo4j::NodeMixin
|
46
|
+
# index :name
|
47
|
+
# has_one :phone
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# class Phone
|
51
|
+
# include Neo4j::NodeMixin
|
52
|
+
# property :phone
|
53
|
+
# node_indexer Contact # put index on the Contact class instead
|
54
|
+
# index :phone
|
55
|
+
# end
|
56
|
+
#
|
57
|
+
# # Find an contact with a phone number, this works since they share the same index
|
58
|
+
# Contact.find('phone: 12345').first #=> a phone object !
|
59
|
+
#
|
30
60
|
# @return [Neo4j::Core::Index::Indexer] The indexer that should be used to index the given class
|
31
61
|
# @see Neo4j::Core::Index::IndexConfig for possible configuration values in the +config_dsl+ block
|
32
62
|
# @yield evaluated in the a Neo4j::Core::Index::IndexConfig object to configure it.
|
33
|
-
def node_indexer(
|
63
|
+
def node_indexer(&config_dsl)
|
64
|
+
# TODO reuse an existing index config
|
65
|
+
config = IndexConfig.new(:node)
|
34
66
|
config.instance_eval(&config_dsl)
|
35
67
|
indexer(config)
|
36
68
|
end
|
@@ -38,32 +70,17 @@ module Neo4j
|
|
38
70
|
# Sets which indexer should be used for the given relationship class
|
39
71
|
# Same as #node_indexer except that it indexes relationships instead of nodes.
|
40
72
|
#
|
41
|
-
# @
|
42
|
-
# @return
|
43
|
-
def rel_indexer(
|
44
|
-
|
45
|
-
indexer(config)
|
73
|
+
# @see #node_indexer
|
74
|
+
# @return [Neo4j::Core::Index::Indexer] The indexer that should be used to index the given class
|
75
|
+
def rel_indexer(clazz)
|
76
|
+
indexer(clazz, :rel)
|
46
77
|
end
|
47
78
|
|
48
|
-
def _config
|
49
|
-
@_indexer && @_indexer.config
|
50
|
-
end
|
51
79
|
|
52
80
|
def indexer(index_config)
|
53
81
|
@_indexer ||= IndexerRegistry.instance.register(Indexer.new(index_config))
|
54
82
|
end
|
55
83
|
|
56
|
-
# You can specify which nodes should be triggered.
|
57
|
-
# The index can be triggered by one or more properties having one or more values.
|
58
|
-
# This can also be done using the #node_indexer or #rel_indexer methods.
|
59
|
-
#
|
60
|
-
# @example trigger on property :type being 'MyType1'
|
61
|
-
# Neo4j::NodeIndex.trigger_on(:type => 'MyType1')
|
62
|
-
#
|
63
|
-
def trigger_on(hash)
|
64
|
-
_config.trigger_on(hash)
|
65
|
-
end
|
66
|
-
|
67
84
|
|
68
85
|
class << self
|
69
86
|
private
|
@@ -76,7 +93,7 @@ module Neo4j
|
|
76
93
|
def delegate(method_name)
|
77
94
|
class_eval(<<-EOM, __FILE__, __LINE__)
|
78
95
|
def #{method_name}(*args, &block)
|
79
|
-
_indexer.send(:#{method_name}, *args, &block)
|
96
|
+
@_indexer.send(:#{method_name}, *args, &block)
|
80
97
|
end
|
81
98
|
EOM
|
82
99
|
end
|
@@ -92,9 +109,6 @@ module Neo4j
|
|
92
109
|
delegate :add_index
|
93
110
|
delegate :rm_index
|
94
111
|
delegate :index_type
|
95
|
-
delegate :index_name_for_type
|
96
|
-
delegate :index_for_type
|
97
|
-
delegate :put_if_absent
|
98
112
|
end
|
99
113
|
|
100
114
|
|
@@ -2,7 +2,7 @@ module Neo4j
|
|
2
2
|
module Core
|
3
3
|
|
4
4
|
# A mixin which adds indexing behaviour to your own Ruby class
|
5
|
-
# You are expected to implement the method `
|
5
|
+
# You are expected to implement the method `wrapped_entity` returning the underlying Neo4j Node or Relationship
|
6
6
|
module Index
|
7
7
|
|
8
8
|
# Adds an index on the given property
|
@@ -16,7 +16,8 @@ module Neo4j
|
|
16
16
|
# @see Neo4j::Core::Index::ClassMethods#add_index
|
17
17
|
#
|
18
18
|
def add_index(field, value=self[field])
|
19
|
-
|
19
|
+
converted_value = Neo4j::TypeConverters.convert(value, field, self.class)
|
20
|
+
self.class.add_index(wrapped_entity, field.to_s, converted_value)
|
20
21
|
end
|
21
22
|
|
22
23
|
# Removes an index on the given property.
|
@@ -26,7 +27,7 @@ module Neo4j
|
|
26
27
|
# @see Neo4j::Core::Index::ClassMethods#rm_index
|
27
28
|
#
|
28
29
|
def rm_index(field, value=self[field])
|
29
|
-
self.class.rm_index(
|
30
|
+
self.class.rm_index(wrapped_entity, field.to_s, value)
|
30
31
|
end
|
31
32
|
|
32
33
|
end
|