Class: Neo4jr::Indexer
- Inherits:
-
Object
- Object
- Neo4jr::Indexer
- Defined in:
- lib/neo4jr/indexer.rb
Constant Summary collapse
- RESERVED_IDENTIFIER_KEY =
'identifier'
Class Method Summary collapse
- .attempt_index(node, property_name, value) ⇒ Object
- .enabled? ⇒ Boolean
- .find_node_by_identifier(identifier_value) ⇒ Object
- .use(service) ⇒ Object
Class Method Details
.attempt_index(node, property_name, value) ⇒ Object
14 15 16 |
# File 'lib/neo4jr/indexer.rb', line 14 def attempt_index(node, property_name, value) @indexer.index(node, RESERVED_IDENTIFIER_KEY, value.to_s) if property_name == RESERVED_IDENTIFIER_KEY end |
.enabled? ⇒ Boolean
10 11 12 |
# File 'lib/neo4jr/indexer.rb', line 10 def enabled? !@indexer.nil? end |
.find_node_by_identifier(identifier_value) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/neo4jr/indexer.rb', line 18 def find_node_by_identifier(identifier_value) hits = @indexer.getNodes(RESERVED_IDENTIFIER_KEY, identifier_value) nodes = hits.iterator results = [] results << nodes.next while nodes.hasNext if results.size > 1 results.sort!{|a, b| a.getId <=> b.getId} results.each_with_index{|node, index| @indexer.removeIndex(node, RESERVED_IDENTIFIER_KEY, identifier_value) if index < results.size} end results.last end |
.use(service) ⇒ Object
6 7 8 |
# File 'lib/neo4jr/indexer.rb', line 6 def use(service) @indexer = LuceneIndexService.new(service) end |