Skip to main content

string

Definition

A string is used whenever you have a column or SQL expression that returns free-text, a URL, Email or any other textual information that you may want to search on, but not refer to its values explicitly.

Usage

Let's take the example of an e-commerce shop and look at a column in our database for returned_comment, so whenever customers return an order, they can specify why in free-text. In this case, it is not natural to model it as a class with entities. A comment doesn't have a name for you to refer to it in a question. But still you may want to explore its contents.

This is how we would model it in the Knowledge Graph:

File: hitchhiker/knowledge-base/classes/Order.vkl

import: [
db.postgres.movie_db.public.ORDERS
]

kb {

class Order {

...

string Comment {
name.en: "Comment"
synonym.en: ["Returned Comment", "Complaint", "Feedback"]

sql: "${ORDERS.returned_comment}"
}
}
}

That's it. Like this, you can ask questions involving text search operations, e.g. "how many customers complained about 'damaged' orders last week?".