Declarative: annotations on fragments
@NodeFragment(labels = ["Proposition"])data class PropositionNode( @NodeId @RangeIndex @Unique val id: String,
@RangeIndex val contextId: String,
val text: String,
@VectorIndex(similarity = SimilarityFunction.COSINE) val embedding: List<Float>?,
@FullTextIndex // full-text index on this property (also drives loadMatching) val body: String,
@TextIndex // Neo4j TEXT index, for CONTAINS / STARTS WITH / ENDS WITH val title: String,)
// Composite declarations go on the class@NodeFragment(labels = ["Message"])@RangeIndex(properties = ["sessionId", "createdAt"])@Unique(properties = ["sessionId", "sequence"])@FullTextIndex(properties = ["subject", "body"]) // multi-property full-text indexdata class MessageNode(/* ... */)Scan them into a catalog — vector dimensions come from your embedding model at runtime, via a VectorDimensionProvider:
@Beanfun schema(embeddingService: EmbeddingService) = SchemaCatalog.fromFragments( VectorDimensionProvider { _, _ -> embeddingService.dimensions }, PropositionNode::class, MessageNode::class,)Works for Java fragments too (SchemaCatalog.fromFragments(JavaNode.class)).
A fragment’s @NodeId gets a range index. Each save, and each load by id, finds its node by the @NodeId property under the fragment’s primary label, and with no index over it a store reads every node of the label. So fromFragments gives each fragment with a @NodeId a range index over that property, unless an item declared serves it: a range index over that property alone, or a uniqueness constraint over it alone, neither ignoring case, from any fragment of the catalog, any catalog merged with it, or any other catalog the SchemaManager applies on that database. It is an item like any other, made by enforce and listed in the owner’s marker. Once made, it stays when a @Unique is later declared on the id (reported as an orphan of its owner), and on Neo4j it is in the way of that constraint (BlockedByIndex): enforce once with drivine.schema.replace-blocking-index=true, or drop the index first. To go without it:
- one fragment:
@NodeFragment(labels = ["Person"], nodeIdIndex = false); - one catalog:
SchemaCatalog.fromFragments(...).withoutNodeIdIndexes(); - every catalog the Spring starter gives the
SchemaManager:drivine.schema.index-node-ids: false.
A fragment never read into a SchemaCatalog gets none. A fragment whose @NodeId no index serves is warned of once per database, at WARN, naming the label, the property and the fix, and the database where there is more than one: after an enforce (or recreateAll), from what it lists of the store, or, where no SchemaManager with a catalog is built, 30 seconds after the fragment’s first use, unless a range index or uniqueness constraint over the @NodeId alone, not ignoring case, under one of its labels, was ensured by hand through indexes or constraints by then. A fragment some catalog was read from (with fromFragments, its default index on or off), or under whose labels some catalog has an item, is checked on the databases those catalogs are for, and on each database it is saved, loaded, counted, searched, deleted, related (edges) or grouped (groups) through a manager of, itself or in a view that holds it, from its first use there; any other fragment is checked on every database. The check never reads the store in a save, and never fails one.
With Spring Boot, the fragments are scanned for you. The starter reads the schema of every @NodeFragment class or interface under the @SpringBootApplication class’s packages (or drivine.schema.scan-packages) and gives it to the SchemaManager beside your catalog beans, so a fragment’s @RangeIndex, @Unique and the rest, and its @NodeId’s range index, are made at startup without a catalog listing it. An item one of your catalog beans declares, under the same kind, label and properties, is left to that bean on the databases it is for, so one you name or tune is made as you declare it there, and the scanned one is made on the others. A fragment with a @VectorIndex is read with your VectorDimensionProvider bean; with none, or several and none primary, it is passed over, said at INFO, and is yours to register in a catalog. A TEXT index is given to the Neo4j databases that manage schema alone, since the other stores refuse one. Scanning never fails startup: fragments that declare conflicting items are passed over together, said at WARN, and the rest applied. What is scanned is applied as a catalog bean is, under drivine.schema.mode, and belongs to the unnamed owner: it is recorded in that owner’s marker, and a version change of your unnamed catalog beans recreates it with theirs. Set drivine.schema.scan-fragments: false to manage the schema through catalog beans alone, as before.

