Released! FalkorDB 4.0-a1 – Vector Search Index & Bolt Protocol

Table of Contents

We are thrilled to announce the release of FalkorDB version 4.0.0-a1, a major update that brings two exciting features to our graph database platform.

Check the new version docker container (we plan to release a cloud sandbox soon)

docker run -it -p 6379:6379 -p 7687:7687 falkordb/falkordb:4.0.0-alpha.1

Notice: the examples bellow are in Java but if Java is not your cup of tea you can find the same examples in other languages here: https://github.com/FalkorDB/demos 

Vector Index

The first feature is Vector Index support, which allows you to find nodes using vector similarity search. This means you can store and query high-dimensional vectors, such as embeddings or image features, and find the most similar nodes based on cosine similarity or Euclidean distance. This opens up new possibilities for applications such as recommendation systems, natural language processing, computer vision, and RAG (we’ll extend in future blogs).

Vector Index example
            package com.falkordb;

import redis.clients.jedis.UnifiedJedis;
import redis.clients.jedis.graph.ResultSet;
import redis.clients.jedis.graph.Record;

public class FalkorDBVectorDemo {
  public static void main(String args[]) {
    try (UnifiedJedis jedis = new UnifiedJedis("redis://localhost:6379")) {

      // Create Vector index on field description in Character
      jedis.graphQuery("Books", "CREATE VECTOR INDEX FOR (c:Character) ON (c.description) OPTIONS {dimension:5, similarityFunction:'euclidean'}");

      // Fill in the Graph with some data on books and characters
      jedis.graphQuery("Books", "CREATE "
        + "(:Character {name:'Bastian Balthazar Bux', description:vecf32([0.1, 0.3, 0.3, 0.4, 0.7])})-[:in]->(book1:Book {name:'The Neverending Story'}), "
        + "(:Character {name:'Atreyu', description:vecf32([0.3, 0.6, 0.2, 0.1, 0.4])})-[:in]->(book1), "
        + "(:Character {name:'Jareth', description:vecf32([0.1, 0.3, 0.1, 0.2, 0.9])})-[:in]->(book2:Book {name:'Labyrinth'}), "
        + "(:Character {name:'Hoggle', description:vecf32([0.3, 0.2, 0.5, 0.7, 0.9])})-[:in]->(book2)");			

      // Find the book with the character description that is most similar (k=1) to the user's query
      ResultSet result = jedis.graphQuery("Books", "CALL db.idx.vector.queryNodes("
        + "'Character', 'description', 1, vecf32([0.1, 0.4, 0.3, 0.2, 0.7])) "
        + "YIELD entity "
        + "MATCH (entity)-[]->(b:Book) "
        + "RETURN b.name AS name");

      // Print out the name
      for (Record record : result) {
        System.out.println(record.getString("name"));
      }
    }
  }
}
        

Bolt Protocol

The second feature is support for Bolt protocol, which allows seamless transition from Neo4J to FalkorDB. If you are already using Neo4J and want to switch to FalkorDB, you can do so without changing your code or your data model. You can use the same drivers and tools that you are familiar with, and enjoy the benefits of FalkorDB’s scalability, performance, and flexibility.

Bolt protocol example

            package com.falkordb;

import redis.clients.jedis.UnifiedJedis;
import redis.clients.jedis.graph.ResultSet;
import redis.clients.jedis.graph.Record;

public class FalkorDBVectorDemo {
  public static void main(String args[]) {
    try (UnifiedJedis jedis = new UnifiedJedis("redis://localhost:6379")) {

      // Create Vector index on field description in Character
      jedis.graphQuery("Books", "CREATE VECTOR INDEX FOR (c:Character) ON (c.description) OPTIONS {dimension:5, similarityFunction:'euclidean'}");

      // Fill in the Graph with some data on books and characters
      jedis.graphQuery("Books", "CREATE "
        + "(:Character {name:'Bastian Balthazar Bux', description:vecf32([0.1, 0.3, 0.3, 0.4, 0.7])})-[:in]->(book1:Book {name:'The Neverending Story'}), "
        + "(:Character {name:'Atreyu', description:vecf32([0.3, 0.6, 0.2, 0.1, 0.4])})-[:in]->(book1), "
        + "(:Character {name:'Jareth', description:vecf32([0.1, 0.3, 0.1, 0.2, 0.9])})-[:in]->(book2:Book {name:'Labyrinth'}), "
        + "(:Character {name:'Hoggle', description:vecf32([0.3, 0.2, 0.5, 0.7, 0.9])})-[:in]->(book2)");			

      // Find the book with the character description that is most similar (k=1) to the user's query
      ResultSet result = jedis.graphQuery("Books", "CALL db.idx.vector.queryNodes("
        + "'Character', 'description', 1, vecf32([0.1, 0.4, 0.3, 0.2, 0.7])) "
        + "YIELD entity "
        + "MATCH (entity)-[]->(b:Book) "
        + "RETURN b.name AS name");

      // Print out the name
      for (Record record : result) {
        System.out.println(record.getString("name"));
      }
    }
  }
}
        
We hope you enjoy the new version of FalkorDB and we look forward to hearing your feedback. Please let us know if you have any questions or issues on our GitHub discussions or our Discord server Happy graphing!

Related Articles

Blog-1.

Code Graph: From Visualization to Integration

Code is the foundation of modern software, but as codebases grow in complexity, understanding and navigating them becomes increasingly challenging. Code Graph is a visual representation of a codebase,…
img-1

Knowledge Graph & LLM or what is GraphRAG?

By using GraphRAG, we can achieve a bidirectional communication between Knowledge Graphs and LLMs, where both sides can benefit from each other’s strengths and compensate for each other’s weaknesses….
Structure of a Knowledge Graph

Knowledge graph vs vector database: Which one to choose?

Large Language Models (LLMs) are powerful Generative AI models that can learn statistical relationships between words, which enables them to generate human-like text, translate languages, write different kinds of…