neo4j 1.0.0.beta.17 → 1.0.0.beta.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -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