Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.neo4j.graphdb.index
Interface Index<T extends PropertyContainer>

Type Parameters:
  `T` - The type of entities this index manages. It may be either `Node`s or `Relationship`s.

All Known Subinterfaces:
  RelationshipIndex

    public interface Index<T extends PropertyContainer>

An index to associate key/value pairs with entities (`Node`s or `Relationship`s) for fast lookup and querying. Any number of key/value pairs can be associated with any number of entities using `add(PropertyContainer, String, Object)` and dissociated with `remove(PropertyContainer, String, Object)`. Querting is done using `get(String, Object)` for exact lookups and `query(Object)` or `query(String, Object)` for more advanced querying, exposing querying capabilities from the backend which is backing this particular index. Write operations participates in transactions so committing and rolling back works the same way as usual in Neo4j.

Author:
  Mattias Persson

Method Summary
`void` | `add(T entity, String key, Object value)` Adds a key/value pair for `entity` to the index.
`void` | `delete()` Clears the index and deletes the configuration associated with it.
`IndexHits<T>` | `get(String key, Object value)` Returns exact matches from this index, given the key/value pair.
`Class<T>` | `getEntityType()`
`String` | `getName()`
`IndexHits<T>` | `query(Object queryOrQueryObject)` Returns matches from this index based on the supplied query object, which can be a query string or an implementation-specific query object.
`IndexHits<T>` | `query(String key, Object queryOrQueryObject)` Returns matches from this index based on the supplied `key` and query object, which can be a query string or an implementation-specific query object.
`void` | `remove(T entity)` Removes an entity from the index and all its key/value pairs which has been previously associated using `add(PropertyContainer, String, Object)`.
`void` | `remove(T entity, String key)` Removes key/value pairs for `entity` where key is `key` from the index.
`void` | `remove(T entity, String key, Object value)` Removes a key/value pair for `entity` from the index.

Method Detail

### getName

    String getName()

  Returns:
    the name of the index, i.e. the name this index was created with.

### getEntityType

    Class<T> getEntityType()

  Returns:
    the type of entities are managed by this index.

### add

    void add(T entity,
             String key,
             Object value)

  Adds a key/value pair for `entity` to the index. If that key/value pair for the entity is already in the index it's up to the implementation to make it so that such an operation is idempotent.

  Parameters:
    `entity` - the entity (i.e `Node` or `Relationship`) to associate the key/value pair with.
    `key` - the key in the key/value pair to associate with the entity.
    `value` - the value in the key/value pair to associate with the entity.

### remove

    void remove(T entity,
                String key,
                Object value)

  Removes a key/value pair for `entity` from the index. If that key/value pair isn't associated with `entity` in this index this operation doesn't do anything.

  Parameters:
    `entity` - the entity (i.e `Node` or `Relationship`) to dissociate the key/value pair from.
    `key` - the key in the key/value pair to dissociate from the entity.
    `value` - the value in the key/value pair to dissociate from the entity.

### remove

    void remove(T entity,
                String key)

  Removes key/value pairs for `entity` where key is `key` from the index. Implementations can choose to not implement this method and should in that case throw `UnsupportedOperationException`.

  Parameters:
    `entity` - the entity (`Node` or `Relationship`) to remove the this index.

### remove

    void remove(T entity)

  Removes an entity from the index and all its key/value pairs which has been previously associated using `add(PropertyContainer, String, Object)`. Implementations can choose to not implement this method and should in that case throw `UnsupportedOperationException`.

  Parameters:
    `entity` - the entity (`Node` or `Relationship`) to remove the this index.

### delete

    void delete()

  Clears the index and deletes the configuration associated with it. After this it's invalid to call any other method on this index. However if the transaction which the delete operation was called in gets rolled back it again becomes ok to use this index.

### get

    IndexHits<T> get(String key,
                     Object value)

  Returns exact matches from this index, given the key/value pair. Matches will be for key/value pairs just as they were added by the `add(PropertyContainer, String, Object)` method.

  Parameters:
    `key` - the key in the key/value pair to match.
    `value` - the value in the key/value pair to match.
  Returns:
    the result wrapped in an `IndexHits` object. If the entire result set isn't looped through, `IndexHits.close()` must be called before disposing of the result.

### query

    IndexHits<T> query(String key,
                       Object queryOrQueryObject)

  Returns matches from this index based on the supplied `key` and query object, which can be a query string or an implementation-specific query object.

  Parameters:
    `key` - the key in this query.
    `queryOrQueryObject` - the query for the `key` to match.
  Returns:
    the result wrapped in an `IndexHits` object. If the entire result set isn't looped through, `IndexHits.close()` must be called before disposing of the result.

### query

    IndexHits<T> query(Object queryOrQueryObject)

  Returns matches from this index based on the supplied query object, which can be a query string or an implementation-specific query object.

  Parameters:
    `queryOrQueryObject` - the query to match.
  Returns:
    the result wrapped in an `IndexHits` object. If the entire result set isn't looped through, `IndexHits.close()` must be called before disposing of the result.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2011 The Neo4j Graph Database Project. All Rights Reserved.