Code Monkey home page Code Monkey logo

azure-cosmos-db-graph-gremlindotnet-getting-started's Introduction

page_type languages products description urlFragment
sample
csharp
azure
Azure Cosmos DB is a globally distributed, multi-model database for mission critical applications.
azure-cosmos-db-graph-gremlindotnet-getting-started

Getting started with Azure Cosmos DB: Graph API

Azure Cosmos DB is a globally distributed, multi-model database for mission critical applications. Azure Cosmos DB provides the Graph API for applications that need to model, query, and traverse large graphs efficiently using the Gremlin standard.

About this sample: Using the Gremlin.Net open-source connector with Cosmos DB and its advantages.

This sample uses the open-source Gremlin.Net driver to connect to an Azure Cosmos DB Graph API account and run some basic Create, Read, Update, Delete Gremlin queries.

Getting Started

Prerequisites

The only dependency is the Gremlin.Net driver version 3.4.13, which you can install with the following instructions:

  • Using .NET CLI:

    dotnet add package Gremlin.Net
    
  • Using Powershell Package Manager:

    Install-Package Gremlin.Net -Version 3.4.13
    
  • For .NET CORE use the nuget command-line utility:

    nuget install Gremlin.Net
    

Input your database identifiers

The program will take the database connection parameters from the environment variables. You'll need to specify the following variables:

  • Host: The endpoint to your Gremlin database. This has the following format xxxx.gremlin.cosmos.azure.com
  • PrimaryKey: Your unique access key to your database. This is a long, secure combination of characters and numbers.
  • DatabaseName: The name of your database that groups your containers.
  • ContainerName: The name of the container, also known as graph, where your data is direclty stored.

You can set an environment variable like this:

  • Powershell: $env:YourVariable="value"
  • CMD: setx YourVariable="value"

Build & Run

From the command prompt where you specified the input environment variables:

  1. Go to GremlinNetSample folder.
  2. Run this command: dotnet run

The sample will run the sequence of queries and print the results and response attributes returned by the Cosmos DB Gremlin API.

Code

The following dictionary, under Program.cs, includes all the Gremlin queries that will be executed serially:

Dictionary<string, string> gremlinQueries = new Dictionary<string, string>
{
    { "Cleanup",        "g.V().drop()" },
    { "AddVertex 1",    "g.addV('person').property('id', 'thomas').property('firstName', 'Thomas').property('age', 44)" },
    { "AddVertex 2",    "g.addV('person').property('id', 'mary').property('firstName', 'Mary').property('lastName', 'Andersen').property('age', 39)" },
    { "AddVertex 3",    "g.addV('person').property('id', 'ben').property('firstName', 'Ben').property('lastName', 'Miller')" },
    { "AddVertex 4",    "g.addV('person').property('id', 'robin').property('firstName', 'Robin').property('lastName', 'Wakefield')" },
    { "AddEdge 1",      "g.V('thomas').addE('knows').to(g.V('mary'))" },
    { "AddEdge 2",      "g.V('thomas').addE('knows').to(g.V('ben'))" },
    { "AddEdge 3",      "g.V('ben').addE('knows').to(g.V('robin'))" },
    { "UpdateVertex",   "g.V('thomas').property('age', 44)" },
    { "CountVertices",  "g.V().count()" },
    { "Filter Range",   "g.V().hasLabel('person').has('age', gt(40))" },
    { "Project",        "g.V().hasLabel('person').values('firstName')" },
    { "Sort",           "g.V().hasLabel('person').order().by('firstName', decr)" },
    { "Traverse",       "g.V('thomas').outE('knows').inV().hasLabel('person')" },
    { "Traverse 2x",    "g.V('thomas').outE('knows').inV().hasLabel('person').outE('knows').inV().hasLabel('person')" },
    { "Loop",           "g.V('thomas').repeat(out()).until(has('id', 'robin')).path()" },
    { "DropEdge",       "g.V('thomas').outE('knows').where(inV().has('id', 'mary')).drop()" },
    { "CountEdges",     "g.E().count()" },
    { "DropVertex",     "g.V('thomas').drop()" },
};

Graph database support overview

Azure Cosmos DB provides you with a fully-managed graph database service with global distribution, elastic scaling of storage and throughput, automatic indexing and query, tunable consistency levels, and supports the Gremlin standard. It also provides the ability to use multiple models like document and graph over the same data. For example, you can use a document collection to store graph data side by side with documents, and use both SQL queries over JSON and Gremlin queries to query the collection. For Graph API, this documentation page lists all the supported Gremlin steps: Azure Cosmos DB Gremlin Graph Support.

azure-cosmos-db-graph-gremlindotnet-getting-started's People

Contributors

danielcweber avatar dependabot[bot] avatar fillo22 avatar jayanta-mondal avatar luisbosquez avatar manishmsfte avatar microsoftopensource avatar msftgits avatar olivertowers avatar snehagunda avatar v-hearya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-cosmos-db-graph-gremlindotnet-getting-started's Issues

Update version of Gremlin.Net from 3.2.7 to latest in the repository.

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [x] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

clone the repository, restore nuget packages

Any log messages given by the failure

Program.cs Line 58
using (var gremlinClient = new GremlinClient(gremlinServer, new GraphSON2Reader(), new GraphSON2Writer(), GremlinClient.GraphSON2MimeType))

"'GremlinClient' does not contain a constructor that takes 4 arguments"

Also, each of the types in the arguments are not found.

Expected/desired behavior

expected to build successfully

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)
windows 10 Professional
visual studio 15.6.4

Versions

Mention any other details that might be useful

packages.config Line 3
<package id="Gremlin.Net" version="3.2.7" targetFramework="net461" />

I noticed the other couple of reported documentation/issues that talked about compatibility etc..

I updated the packages to the latest Gremlin.Net v3.3.1

and that solved the above issues. So I suppose the package file in this repository needs to be updated.

I am moving on to see if I can make this sample work. I hope that my report here will be found useful.

Thank you and I look forward to working with that technology.


Thanks! We'll be in touch soon.

The project Environment Variable do not work in Windows 11

Please provide us with the following information:

This issue is for a: (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Clone project to local machine.
Follow the instructions to add environment variables from your Azure Cosmos DB configuration.
From Windows 11 open Environment Variables from the start menu. Ensure they exist and are correct.
Compile and run in Visual Studio 2022 17.3.6 or higher.
App fails to return environment variables, causing the app to throw hard error.

Any log messages given by the failure

System Environment Variable missing.

Expected/desired behavior

Returns the Environment variable when the Environment.GetEnvironmentVariable("nameofvar") method is executed.

OS and Version?

Windows 11 current build as of 10/2022

Versions

Visual Studio 2022 17.3.6 or higher.

Mention any other details that might be useful


Thanks! We'll be in touch soon.

Gramlin Application POC Set up - Issues

Hi ,
I am trying to set up this application in my environment , facing couple of challenges below.
1.Gramlin.Net library version mentioned in readme is 3.4.6 where as in solution its 3.4.8
2.What should be Host Name , the one with https:// (.NET SDK URI) or Wss:// (Gremlin Endpoint)

I tried with both end points , Poc throws error stating "System.Net.WebSockets.WebSocketException: 'Unable to connect to the remote server'"

As per MS documentation https://docs.microsoft.com/en-us/azure/cosmos-db/graph/create-graph-dotnet
Gremlin Endpoint - This value is used when you connect to the graph account by using Gremlin.Net library.
Capture

Code sample could be improved to allow for fluent API usage and the removal of the injection risk

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [ x] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Not applicable.

Any log messages given by the failure

Not applicable.

Expected/desired behavior

A safer sample that makes more effective use of Gremlin.NET, if possible.

OS and Version?

All.

Versions

All.

Mention any other details that might be useful

We know that Cosmos DB's graph API and Gremlin.NET's fluent API don't quite get on because Cosmos DB's graph API doesn't support bytecode. Moreover, we know that the only way to get Cosmos DB to process a request is to use client.SubmitAsync(). That leaves us with two problems: (1) the cost of writing, debugging, evolving, and maintaining string recipes for Gremlin is prohibitive; and (2) the string interpolation needed to parameterize the recipes introduces an injection risk. That leaves us with one alternative, parse the bytecode into a string and submit that.
Before I go and spend a bunch of time and effort doing this, I'd like to share some initial code for comment:

public static string PrepareSubmission(Bytecode bytecode)
{
    // String optimization.
    // Constants avoid the cost of redefinition.
    const string emptyParentheses = "()";
    const string leftParenthesis = "(";
    const string rightParenthesis = ")";
    const string parameterSeparator = ", ";
    const string period = ".";
    const string escapedQuoteMark = "\'";
    const string quoteMark = "'";
    // Builder addresses cost of concatenation.
    var command = new StringBuilder();

    // Use a for-loop to access the counter.
    for (var i = 0; i < bytecode.StepInstructions.Count; i++)
    {
        // Use a variable to avoid array searches--makes the for-loop perform like a foreach-loop.
        var stepInstruction = bytecode.StepInstructions[i];
        if (i != 0)
        {
            command.Append(period);
        }

        command.Append(stepInstruction.OperatorName);
        if (stepInstruction.Arguments.Length == 0)
        {
            command.Append(emptyParentheses);
            continue;
        }

        command.Append(leftParenthesis);

        // Use a for-loop to access the counter.
        for (var j = 0; j < stepInstruction.Arguments.Length; j++)
        {
            // Use a variable to avoid array searches--makes the for-loop perform like a foreach-loop.
            var arg = stepInstruction.Arguments[j];
            if (j != 0)
            {
                command.Append(parameterSeparator);
            }

            if (arg is string input)
            {
                var scrubber = new StringBuilder(input);
                scrubber.Replace(quoteMark, escapedQuoteMark);

                command.Append(quoteMark);
                command.Append(scrubber.ToString());
                command.Append(quoteMark);

                continue;
            }

            command.Append(quoteMark);
            command.Append(arg.ToString());
            command.Append(quoteMark);
        }

        command.Append(rightParenthesis);
    }

    return command.ToString();
}

Instead of calling Next() or ToList() on the Gremlin API, just build up the query, pass the bytecode to the method, and use a wrapper to run client.SubmitAsync() and process the results.
Any comments or thoughts would be greatly appreciated.

Websocket connection to CosmosDB graph is unstable

Please provide us with the following information:

This issue is for a: (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Checkout the 'FlakyWebsocket' branch from this repo: https://github.com/danielcweber/azure-cosmos-db-graph-gremlindotnet-getting-started/commits/FlakyWebsocket. Build and run. The sample is supposed to run in an in finite loop, however, CosmosDB seems to close the connection at some random point (sometimes after 15 seconds, sometimes 30, sometimes 4 minutes).

Any log messages given by the failure

The most inner exception is a socket exception with native error code 10054 (sorry, german):

System.Net.Sockets.SocketException (0x80004005): Eine vorhandene Verbindung wurde vom Remotehost geschlossen
bei System.Net.Sockets.Socket.BeginSend(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, AsyncCallback callback, Object state)
bei System.Net.Sockets.NetworkStream.BeginWrite(Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)

Expected/desired behavior

Run forever, keep the websocket connection alive.

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Windows 10,

Versions

.net 4.6.1., Gremlinq.net 3.3.1, tested with Gremlinq.net 3.3.2 as well, same results.

Mention any other details that might be useful

The issue is not related to a too large request rate. You can adjust the wait interval, it won't make any difference. The metrics in the CosmosDB dashboard suggest that the used RU/s is way below what is reserved.


Thanks! We'll be in touch soon.

program crashes

"g.V().drop()" }, causes the bottom to happen

System.AggregateException: 'One or more errors occurred. (ServerError:

ActivityId : 00000000-0000-0000-0000-000000000000
ExceptionType : DocumentClientException
ExceptionMessage :
Message: {"Errors":["Resource Not Found. Learn more: https://aka.ms/cosmosdb-tsg-not-found"]}
ActivityId: 8bd9c00a-7efb-41ff-829a-4a38e27ae7d7, Request URI: /apps/DocDbApp/services/DocDbMaster0/partitions/780e44f4-38c8-11e6-8106-8cdcd42c33be/replicas/1p/, RequestStats:
RequestStartTime: 2021-05-02T17:14:12.6027433Z, RequestEndTime: 2021-05-02T17:14:12.6192675Z, Number of regions attempted:1
ResponseTime: 2021-05-02T17:14:12.6192675Z, StoreResult: StorePhysicalAddress: rntbd://127.0.0.1:10251/apps/DocDbApp/services/DocDbMaster0/partitions/780e44f4-38c8-11e6-8106-8cdcd42c33be/replicas/1p/, LSN: 22, GlobalCommittedLsn: -1, PartitionKeyRangeId: , IsValid: True, StatusCode: 404, SubStatusCode: 0, RequestCharge: 1, ItemLSN: -1, SessionToken: -1#22, UsingLocalLSN: False, TransportException: null, ResourceType: Collection, OperationType: Read
ResponseTime: 2021-05-02T17:14:12.6192675Z, StoreResult: StorePhysicalAddress: rntbd://127.0.0.1:10251/apps/DocDbApp/services/DocDbMaster0/partitions/780e44f4-38c8-11e6-8106-8cdcd42c33be/replicas/1p/, LSN: 22, GlobalCommittedLsn: -1, PartitionKeyRangeId: , IsValid: True, StatusCode: 404, SubStatusCode: 0, RequestCharge: 1, ItemLSN: -1, SessionToken: -1#22, UsingLocalLSN: False, TransportException: null, ResourceType: Collection, OperationType: Read
, SDK: Microsoft.Azure.Documents.Common/2.11.0, documentdb-dotnet-sdk/2.11.0 Host/64-bit MicrosoftWindowsNT/6.2.9200.0
Source : Microsoft.Azure.Documents.ClientMessage: {"Errors":["Resource Not Found. Learn more: https://aka.ms/cosmosdb-tsg-not-found"]}
ActivityId: 8bd9c00a-7efb-41ff-829a-4a38e27ae7d7, Request URI: /apps/DocDbApp/services/DocDbMaster0/partitions/780e44f4-38c8-11e6-8106-8cdcd42c33be/replicas/1p/, RequestStats:
RequestStartTime: 2021-05-02T17:14:12.6027433Z, RequestEndTime: 2021-05-02T17:14:12.6192675Z, Number of regions attempted:1
ResponseTime: 2021-05-02T17:14:12.6192675Z, StoreResult: StorePhysicalAddress: rntbd://127.0.0.1:10251/apps/DocDbApp/services/DocDbMaster0/partitions/780e44f4-38c8-11e6-8106-8cdcd42c33be/replicas/1p/, LSN: 22, GlobalCommittedLsn: -1, PartitionKeyRangeId: , IsValid: True, StatusCode: 404, SubStatusCode: 0, RequestCharge: 1, ItemLSN: -1, SessionToken: -1#22, UsingLocalLSN: False, TransportException: null, ResourceType: Collection, OperationType: Read
ResponseTime: 2021-05-02T17:14:12.6192675Z, StoreResult: StorePhysicalAddress: rntbd://127.0.0.1:10251/apps/DocDbApp/services/DocDbMaster0/partitions/780e44f4-38c8-11e6-8106-8cdcd42c33be/replicas/1p/, LSN: 22, GlobalCommittedLsn: -1, PartitionKeyRangeId: , IsValid: True, StatusCode: 404, SubStatusCode: 0, RequestCharge: 1, ItemLSN: -1, SessionToken: -1#22, UsingLocalLSN: False, TransportException: null, ResourceType: Collection, OperationType: Read
, SDK: Microsoft.Azure.Documents.Common/2.11.0, documentdb-dotnet-sdk/2.11.0 Host/64-bit MicrosoftWindowsNT/6.2.9200.0
BackendStatusCode : NotFound
BackendActivityId : 8bd9c00a-7efb-41ff-829a-4a38e27ae7d7
HResult : 0x80131500
)'

Cosmos DB: Gremlin API Request too large exception. How to retry the call

I have a Throughput of 1000 RU/s in my Azure Cosmos DB and I have around 290 queries to be executed. I keep getting request too large exception.

Each query have 12 properties and 1 Partition key but I still think with 1000 RU/s the queries should be executed properly.

I have a gremlinClient

    public static GremlinClient GetGremlinClient()
    {
        var gremlinServer = new GremlinServer(Endpoint, Port, enableSsl: true,
            username: "/dbs/" + Databasename + "/colls/" + Collectionname, password: Authkey);
        var gremlinClient = new GremlinClient(gremlinServer, new GraphSON2Reader(), new GraphSON2Writer(),
            GremlinClient.GraphSON2MimeType);
        return gremlinClient;
    }

A sample query. I am just trying to add vertices

g.addV('Experience').property('_test', 'dummy').property('someProperty', 'dummy').property('someProperty', 'dummy').property('someProperty', 'Documentation of the business processes
of all departments as well as the management level for an informed
selection of an ERP-system for a medium-sized industrial enterprise;
Role: Project management ').property('someProperty',
'2016').property('someProperty', 'Offen').property('someProperty',
'Dummy').property('someProperty', 'EN').property('someProperty',
'Industry').property('someProperty', 'Process documentation of
the whole company for a profounded selection of an ERP-System.')

That for-each executes all the queries

  foreach (string query in queries)
  {
            await gremlinClient.SubmitAsync<dynamic>(query);
  }

The error I get

Server error: \r\n\nActivityId : 2312f64f-b865-49cc-bb26-843d46313199\nExceptionType : RequestRateTooLargeException\nExceptionMessage :\r\n\tMessage: {"Errors":["Request rate is large"]}\r\n\tActivityId: 157daf87-3238-4e1c-9a81-41bcd6d7c2e1, Request URI: /apps/413f848b-ce17-40fc-ad7f-14c0e21e9633/services/29abd22a-4e74-48c1-aab3-b311be968829/partitions/9e4cb405-4f74-4d7f-8d12-26e79b910143/replicas/132142016542682221s/, RequestStats: \r\n\tRequestStartTime: 2019-10-24T09:27:38.2395067Z, RequestEndTime: 2019-10-24T09:27:38.2395067Z, Number of regions attempted:1\r\n\tResponseTime: 2019-10-24T09:27:38.2395067Z

Its a simple code I dont understand what I can change in that.

Is there a way to retry the request for the same point or somehow not get the error or to avoid the error

Old version of Gremlin.NET

This sample explicitly uses an old verion of the Gremlin.NET library. Attempting to build using the latest version errors and shows the constructor used is marked obsolete.

Why does the connection to Cosmos need to be down version. Is is simply that this sample has not been updated or is it because the connection to cosmos doesn't work in later versions?

I'm seeing Gremlin.Net.Driver.Exceptions.ConnectionClosedException when I attmept to run anything against Cosmos when using Gremlin.NET 3.6.1

Docs around connecting to Cosmos gremlin using dotnet are woeful.

Any help understanding why this is doen level much appreciated.

Performance ordering gremlin query results

Hi, I hope that someone could please help me. I have setup a simple test to test query performance for a basic social network. I have included the code below. Basically what I do is create 30000 vertices and then create 20000 edges on one of the vertices.

When I run the following query results are returned quickly: g.V().hasId('partition1').out('friendsWith').valueMap('name', 'profilePicture').range(0,2)

However, as soon as I add an order clause the query takes much, much longer. Over a minute to complete:
g.V().hasId('partition1').out('friendsWith').order().by('name', incr).valueMap('name', 'profilePicture').range(0,2)

Is there a way to index the graph to speed this type of query up?

Thanks very much for the help!

   public async Task<bool> runTests(Models.Person person)
    {
        try
        {
            var gremlinServer = new GremlinServer(_hostname, _port, enableSsl: true,
                                               username: "/dbs/" + _dataBaseId + "/colls/" + _collectionId,
                                               password: _authKey);

            using (var gremlinClient = new GremlinClient(gremlinServer, new GraphSON2Reader(), new GraphSON2Writer(), GremlinClient.GraphSON2MimeType))
            {
                await gremlinClient.SubmitAsync<dynamic>("g.E().drop()");
                await gremlinClient.SubmitAsync<dynamic>("g.V().drop()");

                var counter = 30000;
                while (counter != 0)
                {
                    await gremlinClient.SubmitAsync<dynamic>("g.addV('partition" + counter + "').property('id', 'partition" + counter + "').property('profilePicture', '" + person.ProfilePicture + "').property('name', 'Person " + counter + "').property('partitionKey', 'partition" + counter + "')");
                    counter--;
                }

                var counter = 20000;
                while (counter != 0)
                {
                    int num = counter + 1;
                    var personToLink = "partition" + num;
                    await gremlinClient.SubmitAsync<dynamic>("g.V('partition1').addE('friendsWith').to(g.V('partition" + num + "'))");
                    counter--;
                }

                var searchResults = await gremlinClient.SubmitAsync<dynamic>("g.V().hasId('partition1').out('friendsWith').order().by('name', incr).valueMap('name', 'profilePicture').range(0,2)");

                return true;
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

Change link to Gremlin.Net driver

Hi,
first of all I'm really glad to see that you are helping users of Cosmos DB to use Gremlin.Net.

However, it would be good to change the link from my private repository for Gremlin.Net to the the section in Apache TinkerPop's documentation in your README.md:

This sample uses the open-source [Gremlin.Net driver](https://github.com/FlorianHockmann/Gremlin.Net)

This would be the correct link as you are using version 3.3.0: http://tinkerpop.apache.org/docs/3.3.0/reference/#gremlin-DotNet

The reason is simply that Gremlin.Net is now part of Apache TinkerPop, so I don't maintain the repository anymore. The code of Gremlin.Net can now be found here: https://github.com/apache/tinkerpop/tree/master/gremlin-dotnet

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [x] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

NullReferenceException

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [x] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Downloaded this repo, Change connection information as directed.
Remove all queries from dictionary and replace with single query "g.V().count()"

Any log messages given by the failure

NullReferenceException - last section of stack trace

at Gremlin.Net.Driver.Connection.d__14`1.MoveNext()--- End of stack trace from previous location where exception was thrown ---   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()   at at Gremlin.Net.Driver.Connection.d__14`1.MoveNext()--- End of stack trace from previous location where exception was thrown ---   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()   at
at Gremlin.Net.Driver.Connection.d__14`1.MoveNext()--- End of stack trace from previous location where exception was thrown ---   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()   at

Expected/desired behavior

Return count of Vertex's

OS and Version?

Windows 10

Versions

Gremlin.Net 3.3.1

Mention any other details that might be useful

Can connect to cosmos DB via Gremlin console and by using Microsoft.Azure.Graphs 0.3.1-preview and run traversal queries without error.
Am running in linqpad, but dont think that is the issue. Microsoft.Azure.Graphs works ok in liqpad.

I'm sure it is not the repo, but me. But I've tripple checked everything and cannot see anything wrong.
Looking for suggestions please.


Thanks! We'll be in touch soon.

Question - Incorporating Cosmos Knowledge Graph in RAG

I developed a RAG web service with Azure Cognitive Services, Azure OpenAI API, Azure Cosmos Vector DB. I also built some of the basic blocks of Cosmos Graph DB, but wonder at what stage you integrate it with RAG? That is, does it make sense to do the following: (and if you can't answer, could you forward this to someone who knows):

  1. Generate Relationship (Node1->Edge->Node2) for the prompt text, resulting in a list of Relationships.
  2. For each Relationship and each node and edge: find the 1st-level related nodes and edges.
  3. For each found relationship concatenate nodes and the edge and create Embeddings out of it.
  4. Query the Cosmos vector DB and use the response for additional context for user prompt, along with the results of vector DB search (based on user prompt).

I might be wrong here, but I really would like to know at what stage you incorporate Graph DB querying into RAG.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.