- 
                Notifications
    You must be signed in to change notification settings 
- Fork 64
VECTOR property type constraints #1325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
            stefano-ottolenghi
  merged 10 commits into
  neo4j:dev
from
JPryce-Aklundh:vector_type_constraints
  
      
      
   
  Oct 9, 2025 
      
    
  
     Merged
                    Changes from 4 commits
      Commits
    
    
            Show all changes
          
          
            10 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      23832f8
              
                initial
              
              
                JPryce-Aklundh a72b1bf
              
                label
              
              
                JPryce-Aklundh 0345301
              
                correct xref
              
              
                JPryce-Aklundh b17bcde
              
                cypher 25 info
              
              
                JPryce-Aklundh 55c5df6
              
                show results
              
              
                JPryce-Aklundh cc87333
              
                Merge branch 'dev' into vector_type_constraints
              
              
                JPryce-Aklundh 5a3398d
              
                polish
              
              
                stefano-ottolenghi 1b6869d
              
                note on `null` createStatement
              
              
                stefano-ottolenghi 4d54158
              
                Merge branch 'dev' into vector_type_constraints
              
              
                stefano-ottolenghi ab96f00
              
                Merge branch 'dev' into vector_type_constraints
              
              
                stefano-ottolenghi File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
          Some comments aren't visible on the classic Files Changed page.
        
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|  | @@ -344,6 +344,41 @@ Added 1 constraint. | |||||||||
|  | ||||||||||
| ====== | ||||||||||
|  | ||||||||||
| .Create `VECTOR` property type constraints label:cypher[Cypher 25 only] label:new[Introduced in Neo4j 2025.xx] | ||||||||||
| ====== | ||||||||||
|  | ||||||||||
| It is necessary to specify both the dimension and the coordinate type of any constrained `VECTOR` properties. | ||||||||||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 
        Suggested change
       
 or 
        Suggested change
       
 maybe? sounded odd to me with  | ||||||||||
| The dimension must be greater than `0` and less or equal to `4096`. | ||||||||||
| For more information, see xref:values-and-types/vector.adoc[Values and types -> Vectors]. | ||||||||||
|  | ||||||||||
| .Create a constraint requiring `embedding` properties on `Movie` nodes to be of type `VECTOR<INT32>(42)` | ||||||||||
| [source, cypher] | ||||||||||
| ---- | ||||||||||
| CREATE CONSTRAINT node_vector_constraint | ||||||||||
| FOR (n:Movie) REQUIRE n.embedding IS :: VECTOR<INT32>(42) | ||||||||||
| ---- | ||||||||||
|  | ||||||||||
| .Result | ||||||||||
| [source, queryresult] | ||||||||||
| ---- | ||||||||||
| Added 1 constraint. | ||||||||||
| ---- | ||||||||||
|  | ||||||||||
| .Create a constraint requiring `embedding` properties on `CONTAINS` relationships to be of type `VECTOR<FLOAT32>(1536)` | ||||||||||
| [source, cypher] | ||||||||||
| ---- | ||||||||||
| CREATE CONSTRAINT rel_vector_constraint | ||||||||||
| FOR ()-[r:CONTAINS]->() REQUIRE r.embedding IS :: VECTOR<FLOAT32>(1536) | ||||||||||
| ---- | ||||||||||
|  | ||||||||||
| .Result | ||||||||||
| [source, queryresult] | ||||||||||
| ---- | ||||||||||
| Added 1 constraint. | ||||||||||
| ---- | ||||||||||
|  | ||||||||||
| ====== | ||||||||||
|  | ||||||||||
| [[create-property-type-constraint-union-type]] | ||||||||||
| ==== Create property type constraints with a union type | ||||||||||
|  | ||||||||||
|  | @@ -401,6 +436,7 @@ The allowed property types for property type constraints are: | |||||||||
| * `ZONED DATETIME` | ||||||||||
| * `DURATION` | ||||||||||
| * `POINT` | ||||||||||
| * `VECTOR<TYPE>(DIMENSION)` label:cypher[Cypher 25 only] label:new[Introduced in Neo4j 2025.xx] | ||||||||||
| * `LIST<BOOLEAN NOT NULL>` | ||||||||||
| * `LIST<STRING NOT NULL>` | ||||||||||
| * `LIST<INTEGER NOT NULL>` | ||||||||||
|  | @@ -414,6 +450,10 @@ The allowed property types for property type constraints are: | |||||||||
| * `LIST<POINT NOT NULL>` | ||||||||||
| * Any closed dynamic union of the above types, e.g. `INTEGER | FLOAT | STRING`. | ||||||||||
|  | ||||||||||
| [NOTE] | ||||||||||
| A property type constraint cannot be created for `LIST<VECTOR<TYPE>(DIMENSION) NOT NULL>`. | ||||||||||
| This is because it is not possible to store lists of xref:values-and-types/vector.adoc[`VECTOR`] values. | ||||||||||
|  | ||||||||||
| For a complete reference describing all types available in Cypher, see the section on xref::values-and-types/property-structural-constructed.adoc#types-synonyms[types and their synonyms]. | ||||||||||
|  | ||||||||||
| [[fail-to-create-property-type-constraint-invalid-type]] | ||||||||||
|  | @@ -697,6 +737,7 @@ Additionally, some constraints cannot coexist and attempting to create them toge | |||||||||
| This includes: | ||||||||||
|  | ||||||||||
| * Property type constraints on the same label/relationship type and property but with different property types. | ||||||||||
| This includes `VECTOR` types with differing dimensions or coordinate types. | ||||||||||
| * Property uniqueness and key constraints on the same label/relationship type and property combination. | ||||||||||
|  | ||||||||||
| However, some constraint types are allowed on the same label/relationship type and property combination. | ||||||||||
|  | @@ -1653,6 +1694,9 @@ label:default-output[] | |||||||||
| == DROP CONSTRAINT | ||||||||||
|  | ||||||||||
| Constraints are dropped using the `DROP CONSTRAINT` command. | ||||||||||
| It is possible to drop a constraint that was created in a later Cypher version than the one currently in use. | ||||||||||
| For example, although `VECTOR` property type constraints were added in Cypher 25, such constraints can still be dropped using Cypher 5. | ||||||||||
|  | ||||||||||
| For the full command syntax to drop constraints, see xref:constraints/syntax.adoc#drop-constraint[Syntax -> DROP CONSTRAINT]. | ||||||||||
|  | ||||||||||
| [NOTE] | ||||||||||
|  | ||||||||||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.