Connect Hasura to Weaviate
Weaviate is a cloud-native, modular, real-time vector search engine that allows you to build intelligent applications by using machine learning models as the data layer. It is open-source and can be deployed on-premise or in the cloud.
Step 1: Deploy a data connector agent
We'll use the Hasura CLI to deploy a custom data connector agent to Hasura Cloud. Below, we're using the
command and naming our connector
weaviate-connector:v1. We're also passing in the GitHub repo URL for the connector
agent using the
hasura connector create weaviate-connector:v1 --github-repo-url https://github.com/hasura/weaviate_gdc/tree/main
We can check on the progress of the deployment using the
hasura connector status weaviate-connector:v1
DONE status is returned, we can grab the URL for our data connector agent using the
hasura connector list
This will return a list of all the custom data connector agents you own. The second value returned is the URL which we'll use in the next step; copy it to your clipboard.
Step 2: Add the data connector agent to your Hasura Cloud project
In your Cloud project, navigate to the
Data tab and click
Manage in the left-hand sidebar.
At the bottom of the screen, you'll see an expandable section titled
Data Connector Agents.
Click this and scroll down to
Name this agent
weaviate and paste the URL you copied from the CLI into the
URL field and click
Step 3: Select the driver
Navigate to the
Data tab and select
Connect Database, then select
Weaviate from the list of drivers:
Step 4: Connect your database
At this point, we'll need to configure a few parameters:
|Database Name||The name of your Weaviate database.|
|The API key for your Weaviate database.|
|The URL of your Weaviate database.|
|The OpenAI key for use with your Weaviate database.|
|The URL scheme for your Weaviate database (http/https).|
Step 5: Track your tables
To make schemas accessible for querying using GraphQL, we'll need to track them. In the example below, we're tracking a
Resume by checking the box next to it and clicking
Tracking this schema will generate a type available in your GraphQL API that you can query against 🎉
You will need to define the schema in your vector database. For a walkthrough of setting up a Weaviate schema, refer to this tutorial.
Step 6: Define a remote relationship
The information stored in Weaviate is vectorized and not in a human-readable format. We want to be able to return the information from our relational database using the vectorized data from Weaviate. To do this, we need to define a remote relationship.
In the example below, we're defining a remote relationship between the
Resume schema in our vector database and the
application table in our relational database. This way, whenever we query the vectorized information in our
table, we can return the information from our relational database.
Step 7: Query your data
You can now query across both your vector database and your existing relational database tables as if they were in one location!
In our example, we have two tables in our relational database:
Our vector database stores the resumes as:
If we head to the
API tab in the Hasura Console, in our GraphQL query, we are able to fetch all the candidate and
application information for a resume. Hasura brings this all together to provide this seamless querying experience.