BrainExpanded

Enhancements in Graph Model: Dynamic Entities & Full-Text Search

As I continued work on BrainExpanded and its MCP service, I came to realize that I needed support for dynamic entities and full text search in the Graph Model API. I just published a new release of the Cvoya Graph Model packages with many changes. Here’s a summary:

  • Dynamic Entities. It’s no longer required to use strong types to interact with the graph model. The DynamicNode and DynamicRelationship types provide the necessary support.
  • Full text search. It’s not possible to search the graph using full text search. The PropertyAttribute has been updated to support options related to full text search (e.g. IncludeInFullTextSearch) or to schema-related requirements (e.g. IsRequired, IsUnique).
  • One package dependency. You can now get started easily by just adding the Cvoya.Graph.Model.Neo4j package to your project. The necessary package dependencies will be included and the code generator will be automatically activated at build time of your project. The Cvoya.Graph.Model.Analyzers package is still optional but recommended.
  • All the examples now work. The code for some of the example projects on github was commented out for the last release. They all build and run to completion now. There is an example project for full-text search as well.

Example – Dynamic Entities

You can now use DynamicNode and DynamicRelationship for nodes and relationships:

// Create a node
var node = new DynamicNode(
   labels: new[] { "Person" },
   properties: new Dictionary<string, object?>
   {
      ["name"] = "John Doe",
      ["age"] = 40,
      ["email"] = "john@example.com",
      ["active"] = true
   }
);

await Graph.CreateNodeAsync(node);

It’s similar for relationships.

You can configure the properties using the introduced PropertyConfiguration-related API. Refer to the source code on github for more details. When I get some time, I will write an example and update the documentation.

Of course, it is possible to interact with the created node using a strong type:

public record Person : Node
{
  [Property(Label = "name")]
  public string FullName { get; set; }

  [Property(Label = "age")]
  public int Age { get; set; }

  [Property(Label = "email")]
  public string Email { get; set; }

  [Property(Label = "active")]
  public bool IsActive { get; set; }
}

var person = await graph.Nodes<Person>()
   .Where(p => p.Id = "...")
   .FirstOrDefaultAsync();

Example – Full Text Search

Every entity (node or relationship) with a string property is automatically added to the text index unless otherwise configured. There is a text index per property and a global one. You can search the global index using Search(), node/relationship indexes using SearchNodes() and SearchRelationships, or type-specific indexes using SearchNodes<Person>() and SearchRelationships<FriendsWith>(). You can then compose the search operators with other LINQ queries:

var johnsOver30 = await graph
   .SearchNode<Person>("John")
   .Where(p => p.Age > 30)
   .ToListAsync()

Example – Get started

And now, it’s much easier to get started:

> dotnet new console
> dotnet add package Cvoya.Graph.Model.Neo4j -v 1.0.0-alpha.20250716.4

# optionally but recommended
> dotnet add package Cvoya.Graph.Model.Analyzers -v 1.0.0-alpha.20250716.4

Happy coding!

Savas Parastatidis

Savas Parastatidis works at Amazon as a Sr. Principal Engineer in Alexa AI'. Previously, he worked at Microsoft where he co-founded Cortana and led the effort as the team's architect. While at Microsoft, Savas also worked on distributed data storage and high-performance data processing technologies. He was involved in various e-Science projects while at Microsoft Research where he also investigated technologies related to knowledge representation & reasoning. Savas also worked on language understanding technologies at Facebook. Prior to joining Microsoft, Savas was a Principal Research Associate at Newcastle University where he undertook research in the areas of distributed, service-oriented computing and e-Science. He was also the Chief Software Architect at the North-East Regional e-Science Centre where he oversaw the architecture and the application of Web Services technologies for a number of large research projects. Savas worked as a Senior Software Engineer for Hewlett Packard where he co-lead the R&D effort for the industry's Web Service transactions service and protocol. You can find out more about Savas at https://savas.me/about

Share
Published by
Savas Parastatidis

Recent Posts

The Beginning of CVOYA

There’s a unique energy that comes with starting something new — a blend of excitement,…

3 weeks ago

GraphModel: A .NET Abstraction for Graphs

Just over a month ago, I published "Playing with graphs and Neo4j". Back then, it…

5 months ago

Playing with graphs and neo4j

After my initial implementation of some BrainExpanded-related ideas on top of dgraph using its GraphQL…

6 months ago

A Graph Model DSL

Say hello to the Graph Model Domain Specific Language (GMDSL), created with the help of…

6 months ago

BrainExpanded – Web app and Data Sources

As I wrote in previous posts, the manual recording of memories for BrainExpanded is just…

7 months ago

BrainExpanded – End-to-end working

Imagine a world where your memory is enhanced by a team of intelligent agents, working…

7 months ago