Package org.neo4j.graphdb.schema
Interface Schema
public interface Schema
Interface for managing the schema of your graph database. Please see the Neo4j manual for details.
Compatibility note: New methods may be added to this interface without notice,
backwards compatibility is only guaranteed for clients of this interface, not for
implementors.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
The states that an index can be in. -
Method Summary
Modifier and TypeMethodDescriptionvoid
awaitIndexesOnline
(long duration, TimeUnit unit) Wait until all indices comes onlinevoid
awaitIndexOnline
(String indexName, long duration, TimeUnit unit) Wait until an index with the given name comes online.void
awaitIndexOnline
(IndexDefinition index, long duration, TimeUnit unit) Wait until an index comes onlineconstraintFor
(Label label) Returns aConstraintCreator
where details about the constraint can be specified.Returns aConstraintCreator
where details about the constraint can be specified.getConstraintByName
(String constraintName) Get aConstraintDefinition
by the given name of the constraint.getConstraints
(Label label) getIndexByName
(String indexName) Get anIndexDefinition
by the name of the index.getIndexes
(Label label) getIndexes
(RelationshipType relationshipType) getIndexFailure
(IndexDefinition index) IfgetIndexState(IndexDefinition)
returnSchema.IndexState.FAILED
this method will return the failure description.Poll the database for the population progress.getIndexState
(IndexDefinition index) Poll the database for the state of a given index.Begin specifying an index for all nodes with the given label.Begin specifying an index for all nodes with any of the given labels.indexFor
(RelationshipType type) Begin specifying an index for all relationships with the given relationship type.indexFor
(RelationshipType... types) Begin specifying an index for all relationships with any of the given relationship types.Begin specifying an index of typeIndexType.LOOKUP
for all labels or relationship types.
-
Method Details
-
indexFor
Begin specifying an index for all nodes with the given label. Returns anIndexCreator
where details about the index to create can be specified. When all details have been entered,create
must be called for the index to actually be created. Creating an index enables indexing for nodes with the specified label. The index will have the details supplied to thereturned index creator
. All existing and all future nodes matching the index definition will be indexed, speeding up future read operations.- Parameters:
label
-label
on nodes to be indexed.- Returns:
- an
IndexCreator
capable of providing details for, as well as creating an index for the givenlabel
.
-
indexFor
Begin specifying an index for all nodes with any of the given labels. Returns anIndexCreator
where details about the index to create can be specified. When all details have been entered,create
must be called for the index to actually be created. Creating an index enables indexing for nodes with any of the specified labels. The index will have the details supplied to thereturned index creator
. All existing and all future nodes matching the index definition will be indexed, speeding up future read operations. This behaves similar to theindexFor(Label)
method, with the exception that multiple labels can be specified. Doing so will create a so-called multi-token index. Note that not all index types support multi-token indexes. SeeIndexType
for more information. The list of labels may not contain any duplicates.- Parameters:
labels
- The list of labels for which nodes should be indexed.- Returns:
- an
IndexCreator
capable of providing details for, as well as creating an index for the given list oflabels
.
-
indexFor
Begin specifying an index for all relationships with the given relationship type. Returns anIndexCreator
where details about the index to create can be specified. When all details have been entered,create
must be called for the index to actually be created. Creating an index enables indexing for relationships with the specified relationship type. The index will have the details supplied to thereturned index creator
. All existing and all future relationships matching the index definition will be indexed, speeding up future read operations.- Parameters:
type
-relationship type
on relationships to be indexed.- Returns:
- an
IndexCreator
capable of providing details for, as well as creating an index for the givenRelationshipType
.
-
indexFor
Begin specifying an index for all relationships with any of the given relationship types. Returns anIndexCreator
where details about the index to create can be specified. When all details have been entered,create
must be called for the index to actually be created. Creating an index enables indexing for relationships with any of the specified relationship types. The index will have the details supplied to thereturned index creator
. All existing and all future relationships matching the index definition will be indexed, speeding up future read operations. This behaves similar to theindexFor(RelationshipType)
method, with the exception that multiple relationship types can be specified. Doing so will create a so-called multi-token index. Note that not all index types support multi-token indexes. SeeIndexType
for more information.- Parameters:
types
-relationship types
on relationships to be indexed.- Returns:
- an
IndexCreator
capable of providing details for, as well as creating an index for the givenRelationshipTypes
.
-
indexFor
Begin specifying an index of typeIndexType.LOOKUP
for all labels or relationship types. Returns anIndexCreator
where details about the index to create can be specified. When all details have been entered,create
must be called for the index to actually be created. Creating such index enables indexing for labeled nodes or relationships. The index will have the details supplied to thereturned index creator
. All existing and all future labeled nodes or relationships will be indexed, speeding up future read operations.- Parameters:
tokens
- kind of tokens to be indexed.- Returns:
- an
IndexCreator
capable of providing details for, as well as creating an index for the giventoken type
.
-
getIndexes
-
getIndexes
- Parameters:
relationshipType
- theRelationshipType
to getindexes
for.- Returns:
- all
indexes
attached to the givenrelationship type
.
-
getIndexes
Iterable<IndexDefinition> getIndexes()- Returns:
- all
indexes
in this database.
-
getIndexState
Poll the database for the state of a given index. This can be used to track in which state the creation of the index is, for example if it's stillpopulating
in the background, or has comeonline
.- Parameters:
index
- the index that we want to poll state for- Returns:
- the current
Schema.IndexState
of the index
-
getIndexPopulationProgress
Poll the database for the population progress. This can be used to track the progress of the population job associated to the given index. If the index ispopulating
oronline
, the state will contain current progress. If the index isfailed
then the state returned from this method should be regarded as invalid.- Parameters:
index
- the index that we want to poll state for- Returns:
- the current population progress for the index
-
getIndexFailure
IfgetIndexState(IndexDefinition)
returnSchema.IndexState.FAILED
this method will return the failure description.- Parameters:
index
- theIndexDefinition
to get failure from.- Returns:
- the failure description.
- Throws:
IllegalStateException
- if theindex
isn't in aSchema.IndexState.FAILED
state.
-
constraintFor
Returns aConstraintCreator
where details about the constraint can be specified. When all details have been entered,ConstraintCreator.create()
must be called for it to actually be created. Creating a constraint will block on the create method until all existing data has been verified for compliance. If any existing data doesn't comply with the constraint an exception will be thrown, and the constraint will not be created.- Parameters:
label
- the label this constraint is for.- Returns:
- a
ConstraintCreator
capable of providing details for, as well as creating a constraint for the given label.
-
constraintFor
Returns aConstraintCreator
where details about the constraint can be specified. When all details have been entered,ConstraintCreator.create()
must be called for it the actually be created. Creating a constraint will block on the create method until all existing data has been verified for compliance. If any existing data doesn't comply with the constraint an exception will be thrown, and the constraint will not be created.- Parameters:
type
- the relationship type this constraint is for.- Returns:
- a
ConstraintCreator
capable of providing details for, as well as creating a constraint for the given RelationshipType.
-
getConstraints
- Parameters:
label
- the label to get constraints for.- Returns:
- all constraints for the given label.
-
getConstraints
- Parameters:
type
- the relationship type to get constraints for.- Returns:
- all constraints for the given relationship type.
-
getConstraints
Iterable<ConstraintDefinition> getConstraints()- Returns:
- all constraints
-
awaitIndexOnline
Wait until an index comes online- Parameters:
index
- the index that we want to wait forduration
- duration to wait for the index to come onlineunit
- TimeUnit of duration- Throws:
IllegalStateException
- if the index did not enter the ONLINE state within the given duration or if the index entered the FAILED state
-
awaitIndexOnline
Wait until an index with the given name comes online.- Parameters:
indexName
- the name of the index that we want to wait for.duration
- duration to wait for the index to come onlineunit
- TimeUnit of duration- Throws:
IllegalStateException
- if the index did not enter the ONLINE state within the given duration, or if the index entered the FAILED state.
-
awaitIndexesOnline
Wait until all indices comes online- Parameters:
duration
- duration to wait for all indexes to come onlineunit
- TimeUnit of duration- Throws:
IllegalStateException
- if some index did not enter the ONLINE state within the given duration or if the index entered the FAILED state
-
getConstraintByName
Get aConstraintDefinition
by the given name of the constraint.- Parameters:
constraintName
- The name of the constraint.- Returns:
- The constraint with that name.
- Throws:
IllegalArgumentException
- if there is no constraint with that name.
-
getIndexByName
Get anIndexDefinition
by the name of the index.- Parameters:
indexName
- The name of the index.- Returns:
- The index with that name.
- Throws:
IllegalArgumentException
- if there is no index with that name.
-