neo4j 1.0.0.beta.17 → 1.0.0.beta.18
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.
- data/Gemfile +2 -2
- data/README.rdoc +2 -2
- data/lib/generators/neo4j.rb +65 -0
- data/lib/generators/neo4j/model/model_generator.rb +39 -0
- data/lib/generators/neo4j/model/templates/model.rb +7 -0
- data/lib/neo4j.rb +2 -2
- data/lib/neo4j/config.rb +14 -12
- data/lib/neo4j/database.rb +1 -1
- data/lib/neo4j/equal.rb +3 -0
- data/lib/neo4j/event_handler.rb +25 -14
- data/lib/neo4j/index/class_methods.rb +3 -2
- data/lib/neo4j/index/indexer.rb +121 -21
- data/lib/neo4j/index/lucene_query.rb +156 -0
- data/lib/neo4j/load.rb +3 -2
- data/lib/neo4j/mapping/class_methods/property.rb +16 -0
- data/lib/neo4j/mapping/class_methods/relationship.rb +3 -1
- data/lib/neo4j/mapping/class_methods/root.rb +3 -0
- data/lib/neo4j/mapping/class_methods/rule.rb +141 -66
- data/lib/neo4j/mapping/decl_relationship_dsl.rb +8 -8
- data/lib/neo4j/mapping/has_n.rb +11 -1
- data/lib/neo4j/mapping/node_mixin.rb +20 -0
- data/lib/neo4j/neo4j.rb +24 -5
- data/lib/neo4j/node.rb +1 -1
- data/lib/neo4j/property.rb +1 -1
- data/lib/neo4j/rails/model.rb +40 -36
- data/lib/neo4j/rails/properties.rb +29 -0
- data/lib/neo4j/rails/value.rb +8 -29
- data/lib/neo4j/transaction.rb +0 -1
- data/lib/neo4j/version.rb +1 -1
- metadata +8 -5
- data/lib/neo4j/index/wrapped_query.rb +0 -59
- data/lib/neo4j/mapping/class_methods/index.rb +0 -17
@@ -1,59 +0,0 @@
|
|
1
|
-
module Neo4j
|
2
|
-
module Index
|
3
|
-
|
4
|
-
class WrappedQuery
|
5
|
-
include Enumerable
|
6
|
-
|
7
|
-
def initialize(index, query)
|
8
|
-
@index = index
|
9
|
-
@query = query
|
10
|
-
end
|
11
|
-
|
12
|
-
def each
|
13
|
-
hits.each { |n| yield n.wrapper }
|
14
|
-
end
|
15
|
-
|
16
|
-
def close
|
17
|
-
@hits.close if @hits
|
18
|
-
end
|
19
|
-
|
20
|
-
def empty?
|
21
|
-
hits.size == 0
|
22
|
-
end
|
23
|
-
|
24
|
-
def [](index)
|
25
|
-
each_with_index {|node,i| break node if index == i}
|
26
|
-
end
|
27
|
-
|
28
|
-
def size
|
29
|
-
hits.size
|
30
|
-
end
|
31
|
-
|
32
|
-
def hits
|
33
|
-
@hits ||= perform_query
|
34
|
-
end
|
35
|
-
|
36
|
-
def desc(*fields)
|
37
|
-
@order = fields.inject(@order || {}) { |memo, field| memo[field] = true; memo }
|
38
|
-
self
|
39
|
-
end
|
40
|
-
|
41
|
-
def asc(*fields)
|
42
|
-
@order = fields.inject(@order || {}) { |memo, field| memo[field] = false; memo }
|
43
|
-
self
|
44
|
-
end
|
45
|
-
|
46
|
-
def perform_query
|
47
|
-
if @order
|
48
|
-
java_sort_fields = @order.keys.inject([]) do |memo, field|
|
49
|
-
memo << org.apache.lucene.search.SortField.new(field.to_s, org.apache.lucene.search.SortField::STRING, @order[field])
|
50
|
-
end
|
51
|
-
sort = org.apache.lucene.search.Sort.new(*java_sort_fields)
|
52
|
-
@query = org.neo4j.index.impl.lucene.QueryContext.new(@query).sort(sort)
|
53
|
-
end
|
54
|
-
@index.query(@query)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Neo4j::Mapping
|
2
|
-
module ClassMethods
|
3
|
-
module Index
|
4
|
-
def index(field, config = {})
|
5
|
-
Neo4j::Node.index(field, config, index_name)
|
6
|
-
end
|
7
|
-
|
8
|
-
def find(field, query, config = {})
|
9
|
-
Neo4j::Node.find(field, query, config, index_name)
|
10
|
-
end
|
11
|
-
|
12
|
-
def rm_index(field, config = {})
|
13
|
-
Neo4j::Node.rm_index(field, config, index_name)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|