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

- (Object) _indexer (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

- (Object) _config



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

def _config
  @_indexer && @_indexer.config
end

- (Object) add_index(*args, &block)

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

- (Object) find(*args, &block)

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

- (Object) has_index_type?(*args, &block)

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?

- (Object) index(*args, &block)

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

- (Object) index?(*args, &block)

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?

- (Object) index_for_type(*args, &block)

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

- (Object) index_name_for_type(*args, &block)

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

- (Object) index_type(*args, &block)

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

- (Object) indexer(index_config)



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

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

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

- (Object) put_if_absent(*args, &block)

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

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

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

- (Object) rm_index(*args, &block)

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

- (Object) rm_index_config(*args, &block)

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

- (Object) rm_index_type(*args, &block)

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

- (Object) trigger_on(hash)

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