Neo4j Server: Indices

Bulbs API for the Neo4j Server indices.

Exact Index

class bulbs.neo4jserver.index.ExactIndex(client, result)[source]

Neo4j’s Lucence exact index.

Variables:
  • index_type – Index type.
  • index_provider – Index provider.
  • blueprints_type – Blueprints type.
  • client – Neo4jClient object
  • result – Neo4jResult object.
query(key, query_string)[source]

Return all the elements in the index matching the query.

Parameters:
  • key (str) – The index key.
  • query_string – The query string. Example: “Jam*”.
Return type:

Element generator

count(key=None, value=None, **pair)

Return the number of items in the index for the key and value.

Parameters:
  • key (str) – The index key.
  • value (str or int) – The key’s value.
  • pair (name/value pair) – Optional key/value pair. Example: name=”James”
Return type:

int

classmethod get_proxy_class(base_type)

Returns the IndexProxy class.

Parameters:base_type (str) – Index base type, either vertex or edge.
Return type:class
get_unique(key=None, value=None, **pair)

Returns a max of 1 elements in the index matching the key/value pair.

Parameters:
  • key (str) – The index key.
  • value (str or int) – The key’s value.
  • pair (key/value pair) – Optional key/value pair. Example: name=”James”
Return type:

Element or None

index_class

Returns the index class, either vertex or edge.

Return type:class
index_name

Returns the index name.

Return type:str
lookup(key=None, value=None, **pair)

Return all the elements in the index where key equals value.

Parameters:
  • key (str) – The index key.
  • value (str or int) – The key’s value.
  • pair (key/value pair) – Optional key/value pair. Example: name=”James”
Return type:

Element generator

put(_id, key=None, value=None, **pair)

Put an element into the index at key/value and return the Response.

Parameters:
  • _id (int or str) – The element ID.
  • key (str) – The index key.
  • value (str or int) – The key’s value.
  • pair (name/value pair) – Optional key/value pair. Example: name=”James”
Return type:

bulbs.neo4jserver.client.Neo4jResponse

put_unique(_id, key=None, value=None, **pair)

Put an element into the index at key/value and overwrite it if an element already exists; thus, when you do a lookup on that key/value pair, there will be a max of 1 element returned.

Parameters:
  • key (str) – The index key.
  • value (str or int) – The key’s value.
  • pair (key/value pair) – Optional key/value pair. Example: name=”James”
Return type:

bulbs.neo4jserver.client.Neo4jResponse

remove(_id, key=None, value=None, **pair)

Remove the element from the index located by key/value.

Parameters:
  • key (str) – The index key.
  • value (str or int) – The key’s value.
  • pair (key/value pair) – Optional key/value pair. Example: name=”James”
Return type:

bulbs.neo4jserver.client.Neo4jResponse

update(_id, key=None, value=None, **pair)

Update the element ID for the key and value.

Parameters:
  • key (str) – The index key.
  • value (str or int) – The key’s value.
  • pair (key/value pair) – Optional key/value pair. Example: name=”James”
Return type:

bulbs.neo4jserver.client.Neo4jResponse

Fulltext Index

class bulbs.neo4jserver.index.FulltextIndex(client, result)[source]

Neo4j’s Lucence fulltext index.

Variables:
  • index_type – Index type.
  • index_provider – Index provider.
  • blueprints_type – Blueprints type.
  • client – Neo4jClient object
  • result – Neo4jResult object.
query(query_string)[source]

Return elements mathing the query.

See http://lucene.apache.org/core/3_6_0/queryparsersyntax.html

Parameters:query_string (str) – The query formatted in the Lucene query language.
Return type:Element generator
count(key=None, value=None, **pair)

Return the number of items in the index for the key and value.

Parameters:
  • key (str) – The index key.
  • value (str or int) – The key’s value.
  • pair (name/value pair) – Optional key/value pair. Example: name=”James”
Return type:

int

classmethod get_proxy_class(base_type)

Returns the IndexProxy class.

Parameters:base_type (str) – Index base type, either vertex or edge.
Return type:class
get_unique(key=None, value=None, **pair)

Returns a max of 1 elements in the index matching the key/value pair.

Parameters:
  • key (str) – The index key.
  • value (str or int) – The key’s value.
  • pair (key/value pair) – Optional key/value pair. Example: name=”James”
Return type:

Element or None

index_class

Returns the index class, either vertex or edge.

Return type:class
index_name

Returns the index name.

Return type:str
lookup(key=None, value=None, **pair)

Return all the elements in the index where key equals value.

Parameters:
  • key (str) – The index key.
  • value (str or int) – The key’s value.
  • pair (key/value pair) – Optional key/value pair. Example: name=”James”
Return type:

Element generator

put(_id, key=None, value=None, **pair)

Put an element into the index at key/value and return the Response.

Parameters:
  • _id (int or str) – The element ID.
  • key (str) – The index key.
  • value (str or int) – The key’s value.
  • pair (name/value pair) – Optional key/value pair. Example: name=”James”
Return type:

bulbs.neo4jserver.client.Neo4jResponse

put_unique(_id, key=None, value=None, **pair)

Put an element into the index at key/value and overwrite it if an element already exists; thus, when you do a lookup on that key/value pair, there will be a max of 1 element returned.

Parameters:
  • key (str) – The index key.
  • value (str or int) – The key’s value.
  • pair (key/value pair) – Optional key/value pair. Example: name=”James”
Return type:

bulbs.neo4jserver.client.Neo4jResponse

remove(_id, key=None, value=None, **pair)

Remove the element from the index located by key/value.

Parameters:
  • key (str) – The index key.
  • value (str or int) – The key’s value.
  • pair (key/value pair) – Optional key/value pair. Example: name=”James”
Return type:

bulbs.neo4jserver.client.Neo4jResponse

update(_id, key=None, value=None, **pair)

Update the element ID for the key and value.

Parameters:
  • key (str) – The index key.
  • value (str or int) – The key’s value.
  • pair (key/value pair) – Optional key/value pair. Example: name=”James”
Return type:

bulbs.neo4jserver.client.Neo4jResponse

Vertex Index Proxy

class bulbs.neo4jserver.index.VertexIndexProxy(index_class, client)[source]

Manage vertex indices on Neo4j Server.

Parameters:
Variables:
  • index_class – Index class.
  • client – Neo4jClient object.
create(index_name)[source]

Creates an Vertex index and returns it.

Parameters:index_name (str) – Index name.
Return type:bulbs.neo4jserver.index.Index
get(index_name)[source]

Returns the Index object with the specified name or None if not found.

Parameters:index_name (str) – Index name.
Return type:bulbs.neo4jserver.index.Index
get_or_create(index_name)[source]

Get a Vertex Index or create it if it doesn’t exist.

Parameters:index_name (str) – Index name.
Return type:bulbs.neo4jserver.index.Index
delete(index_name)[source]

Deletes an index and returns the Response.

Parameters:index_name (str) – Index name.
Return type:bulbs.neo4jserver.client.Neo4jResponse

Edge Index Proxy

class bulbs.neo4jserver.index.EdgeIndexProxy(index_class, client)[source]

Manage edge indices on Neo4j Server.

Parameters:
Variables:
  • index_class – Index class.
  • client – Neo4jClient object.
create(index_name)[source]

Creates an Edge index and returns it.

Parameters:index_name (str) – Index name.
Return type:bulbs.neo4jserver.index.Index
get(index_name)[source]

Returns the Index object with the specified name or None if not found.

Parameters:index_name (str) – Index name.
Return type:bulbs.neo4jserver.index.Index
get_or_create(index_name)[source]

Get an Edge Index or create it if it doesn’t exist.

Parameters:index_name (str) – Index name.
Return type:bulbs.neo4jserver.index.Index
delete(index_name)[source]

Deletes an index and returns the Response.

Parameters:index_name (str) – Index name.
Return type:bulbs.neo4jserver.client.Neo4jResponse