Skip to main content

Knowledge Graph Sync

Why keep your Knowledge Graph synchronized?

The Knowledge Graph is a semantic representation of your data and, because of that, it needs to know the values (entities) in your data.

When we talk about synchronizing the Knowledge Graph, we mean keeping these database values up-to-date, not the database schema.

Let's say you've imported a table containing the products you sell. These products may change in the future and Veezoo should know about these changes, so you can ask about the new products.

Notice here that the Knowledge Graph will contain the individual distinct values of a database column (e.g. your products), but not all the rows in your database (e.g. all the transactions from these products and the revenue, etc). In other words, the Knowledge Graph is used to understand a question, not to answer it.

How do I synchronize it?

Manual Sync

By default, Veezoo does not automatically schedule to sync the Knowledge Graph.

So the most common way to sync it is by:

  1. Open in Veezoo Studio the file for the class you want to sync (under knowledge-base/classes/...). You can get there quickly by going to the Knowledge Graph sidebar, hovering over the class and clicking to "Open in Studio" in the info panel.

Open in Veezoo Studio

  1. You will notice on the top bar of the file a sync icon.

Sync Button

  1. Click on it and select the classes you want to sync.

Choose Classes

  1. Wait... and that's it.

Success

Scheduled Sync

If there are always new individual values being added, you may want to schedule your sync to run with a certain frequency.

To do that, you will need to:

  1. Open Veezoo Studio and open the file for each class you want to schedule the sync.

  2. Inside each class you want to sync, add a sync_policy:

    • If you want to keep changes you may have done to the entities (e.g. synonyms, renaming), add: sync_policy: "merge"

    • If you want to always replace the entities with the new ones: sync_policy: "replace"


kb {
class Product {
name.en: "Product"

from_table: product
sql: "${product.product_id}"
name_sql.en: "${product.product_name}"

extends: onto.Product

sync_policy: "replace"

class Category {
name.en: "Category"

sync_policy: "merge"

sql: "${product.category}"
}

class Sub_Category {
name.en: "Sub Category"

sql: "${product.sub_category}"
}
}
}

  1. Save and go back to the Configuration view for your Knowledge Graph in Veezoo Studio.

  2. Modify the field Synchronization Schedule by adding a cron expression (in UTC) for the frequency.

    • You can use this website to find out the appropriate cron expression.

    • If the cron expression is for more often than once a day, it may incur extra costs. So use something like "every day at 03 AM": 0 0 3 ? * * *

Configuration

  1. Save it and that's it.