Module: Neo4j::Core::Index::ClassMethods

Included in:
Node, Relationship
Defined in:
lib/neo4j-core/index/class_methods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_indexerObject (readonly)

The indexer which we are delegating to



7
8
9
# File 'lib/neo4j-core/index/class_methods.rb', line 7

def _indexer
  @_indexer
end

Instance Method Details

#_configObject



48
49
50
# File 'lib/neo4j-core/index/class_methods.rb', line 48

def _config
  @_indexer && @_indexer.config
end

#add_index(*args, &block) ⇒ Object

Delegates the ‘add_index` message to @_indexer instance with the supplied parameters.

See Also:



92
# File 'lib/neo4j-core/index/class_methods.rb', line 92

delegate :add_index

#find(*args, &block) ⇒ Object

Delegates the ‘find` message to @_indexer instance with the supplied parameters.

See Also:



87
# File 'lib/neo4j-core/index/class_methods.rb', line 87

delegate :find

#has_index_type?(*args, &block) ⇒ Object

Delegates the ‘has_index_type?` message to @_indexer instance with the supplied parameters.



89
# File 'lib/neo4j-core/index/class_methods.rb', line 89

delegate :has_index_type?

#index(*args, &block) ⇒ Object

Delegates the ‘index` message to @_indexer instance with the supplied parameters.

See Also:



86
# File 'lib/neo4j-core/index/class_methods.rb', line 86

delegate :index

#index?(*args, &block) ⇒ Object

Delegates the ‘index?` message to @_indexer instance with the supplied parameters.

See Also:



88
# File 'lib/neo4j-core/index/class_methods.rb', line 88

delegate :index?

#index_for_type(*args, &block) ⇒ Object

Delegates the ‘index_for_type` message to @_indexer instance with the supplied parameters.



96
# File 'lib/neo4j-core/index/class_methods.rb', line 96

delegate :index_for_type

#index_name_for_type(*args, &block) ⇒ Object

Delegates the ‘index_name_for_type` message to @_indexer instance with the supplied parameters.



95
# File 'lib/neo4j-core/index/class_methods.rb', line 95

delegate :index_name_for_type

#index_type(*args, &block) ⇒ Object

Delegates the ‘index_type` message to @_indexer instance with the supplied parameters.

See Also:



94
# File 'lib/neo4j-core/index/class_methods.rb', line 94

delegate :index_type

#indexer(index_config) ⇒ Object



52
53
54
# File 'lib/neo4j-core/index/class_methods.rb', line 52

def indexer(index_config)
  @_indexer ||= IndexerRegistry.instance.register(Indexer.new(index_config))
end

#node_indexer(config = _config || IndexConfig.new(:node)) { ... } ⇒ Neo4j::Core::Index::Indexer

Sets which indexer should be used for the given node class. You can share an indexer between several different classes.

Examples:

Using custom index


class MyIndex
   extend Neo4j::Core::Index::ClassMethods
   include Neo4j::Core::Index

   node_indexer do
     index_names :exact => 'myindex_exact', :fulltext => 'myindex_fulltext'
     trigger_on :ntype => 'foo', :name => ['bar', 'foobar']

     prefix_index_name do
       "Foo"  # this is used for example in multitenancy to let each domain have there own index files
     end
   end
end

Parameters:

Yields:

  • evaluated in the a Neo4j::Core::Index::IndexConfig object to configure it.

Returns:

See Also:



33
34
35
36
# File 'lib/neo4j-core/index/class_methods.rb', line 33

def node_indexer(config = _config || IndexConfig.new(:node), &config_dsl)
  config.instance_eval(&config_dsl)
  indexer(config)
end

#put_if_absent(*args, &block) ⇒ Object

Delegates the ‘put_if_absent` message to @_indexer instance with the supplied parameters.



97
# File 'lib/neo4j-core/index/class_methods.rb', line 97

delegate :put_if_absent

#rel_indexer(config = _config || IndexConfig.new(:rel), &config_dsl) ⇒ Neo4j::Core::Index::Indexer

Sets which indexer should be used for the given relationship class Same as #node_indexer except that it indexes relationships instead of nodes.

Parameters:

Returns:



43
44
45
46
# File 'lib/neo4j-core/index/class_methods.rb', line 43

def rel_indexer(config = _config || IndexConfig.new(:rel), &config_dsl)
  config.instance_eval(&config_dsl)
  indexer(config)
end

#rm_index(*args, &block) ⇒ Object

Delegates the ‘rm_index` message to @_indexer instance with the supplied parameters.

See Also:



93
# File 'lib/neo4j-core/index/class_methods.rb', line 93

delegate :rm_index

#rm_index_config(*args, &block) ⇒ Object

Delegates the ‘rm_index_config` message to @_indexer instance with the supplied parameters.



91
# File 'lib/neo4j-core/index/class_methods.rb', line 91

delegate :rm_index_config

#rm_index_type(*args, &block) ⇒ Object

Delegates the ‘rm_index_type` message to @_indexer instance with the supplied parameters.



90
# File 'lib/neo4j-core/index/class_methods.rb', line 90

delegate :rm_index_type

#trigger_on(hash) ⇒ Object

You can specify which nodes should be triggered. The index can be triggered by one or more properties having one or more values. This can also be done using the #node_indexer or #rel_indexer methods.

Examples:

trigger on property :type being ‘MyType1’

Neo4j::NodeIndex.trigger_on(:type => 'MyType1')


63
64
65
# File 'lib/neo4j-core/index/class_methods.rb', line 63

def trigger_on(hash)
  _config.trigger_on(hash)
end