The elixir of HelixDB
Continent
node will have a name
property (String)Country
node will have: name
(String), currency
(String), population
(U64), and gdp
(F64)City
node will have: name
(String), description
(String), and zip_codes
(array of strings)Continent
, Country
, and City
node with their respective properties in schema.hx
.Answer
Continent_to_Country
and Country_to_City
edge connecting their respective nodes with no properties in schema.hx
.Answer
Country_to_Capital
edge connecting Country
to City
in schema.hx
.Answer
CityDescription
vector with vector
property that takes an array of F64
.Answer
AddN
to add a Continent
node with property name
. For best practices, make sure to return the continent that was added in your query.
Instructions:
Continent
node in queries.hx
.createContinent
name
: StringAnswer
Country
node and connect it to its corresponding Continent
node. First we will first create a new Country
node using AddN
. Then we will get the Continent
node via the node’s ID so that we can create a Continent_to_Country
edge going from the created Continent
to Country
node using AddE
. We will also do the same thing for creating a City
node.
Instructions:
Country
node and connect it to its respective Continent
node by continent ID.
City
node and connect it to its respective Country
node by country ID.
createCountry
continent_id
: IDname
: Stringcurrency
: Stringpopulation
: I64gdp
: F64createCity
country_id
: IDname
: Stringdescription
: StringAnswer
Country_to_Capital
edge from a Country
node to a City
node.
Instructions:
City
node as the capital city of a Country
node using their IDs.setCapital
country_id
: IDcity_id
: IDAnswer
CityDescription
vector and connect it to its respective City
node by city ID.
Query Parameters:
embedDescription
city_id
: IDvector
: [F64]Answer
Continent
, Country
, and City
by node ID.getContinent
continent_id
: IDgetCountry
country_id
: IDgetCity
city_id
: IDAnswer
Continent
, Country
, and City
nodes.
Country
and City
nodes by their parent IDs.
getAllContinents
getAllCountries
getAllCities
getCountriesInContinent
continent_id
: IDgetCitiesInCountry
country_id
: IDAnswer
Country_to_Capital
edge from a Country
node to find its capital City
node.
Instructions:
City
node by the country’s ID.getCapital
country_id
: IDAnswer
name
and population
.getCountryNames
Answer
Continent
, Country
, and City
nodes by their names.getContinentByName
continent_name
: StringgetCountryByName
country_name
: StringgetCityByName
city_name
: StringAnswer
Country
nodes by their currency.
Country
nodes with population less than max_population
.
Country
nodes with GDP greater than or equal to min_gdp
.
getCountriesByCurrency
currency
: StringgetCountriesByPopulation
max_population
: I64getCountriesByGdp
min_gdp
: F64Answer
Country
nodes based on a combination of property values. This includes filtering countries with a population greater than a minimum and a GDP less than or equal to a maximum, as well as retrieving countries that either use a specific currency or have a population below a certain threshold. These types of queries allow us to refine our searches and extract more targeted subsets of data from our graph.
Instructions:
Country
nodes with both population greater than min_population
and GDP less than or equal to max_gdp
.
Country
nodes with either a specific currency
or a population less than or equal to max_population
.
getCountriesByPopGdp
min_population
: I64max_gdp
: F64getCitiesByCurrPop
currency
: Stringmax_population
: I64Answer
Country
nodes that have a capital city assigned. This involves checking for the existence of an outgoing Country_to_Capital
edge from each Country
node. Meta relationship queries like this are useful for identifying nodes with specific contextual connections beyond hierarchical structures.
Instructions:
Write a query to get Country
nodes that have capital cities.
Query Parameters:
getCountriesWithCapitals
Answer
RANGE
operator allows you to implement pagination and control result set size efficiently. This is particularly important for performance when dealing with queries that might return many nodes. The RANGE
operator takes two parameters: the starting index (0-based) and the number of items to return.
Instructions:
k
(I64
) City
nodes in a continent given the continent’s name.getContinentCities
continent_name
: Stringk
: I64Answer
City
nodes have an incoming Country_to_Capital
edge. Using the COUNT
operation, we can quickly compute aggregate statistics like this to better understand the structure and distribution of data across our graph.
Instructions:
countCapitals
Answer
Country_to_City
edges from each Country
node and filter by num_cities
. This pattern of anonymous traversal is useful when we care about the structure or degree of connectivity in the graph, rather than the specific linked nodes themselves.
Instructions:
Country
nodes that has more cities than num_cities
.getCountryByCityCnt
num_cities
: I64Answer
CityDescription
vectors, we can retrieve the top-k
most semantically similar City
nodes to a given input vector. This is especially useful when we want to find cities that share common characteristics or themes, even if their properties don’t match exactly.
vector
against CityDescription
vectors and returning the top k
City
nodes.searchDescriptions
vector
: [F64]k
: I64Answer
UPDATE
operation followed by the fields we want to modify. For example, we can update a country’s currency
by its ID
, or simultaneously update both its population
and GDP
. Keeping node data up-to-date ensures our graph remains accurate and relevant for queries, visualizations, and downstream analytics.
Instructions:
currency
by a country’s ID.
population
and gdp
by a country’s ID.
updateCurrency
country_id
: IDcurrency
: StringupdatePopGdp
country_id
: IDpopulation
: I64gdp
: F64Answer
City
node given its ID.
City
node given its country’s ID.
Country
node given its ID.
deleteCity
city_id
: IDdeleteCapital
country_id
: IDdeleteCountry
country_id
: IDAnswer
City
node of a Coutry
node given the country’s ID and the new capital city’s ID.updateCapital
country_id
: IDcity_id
: IDAnswer
description
of a City
node given its ID and also update the CityDescription
vector embedding given a new vector
.updateDescription
city_id
: IDdescription
: Stringvector
: [F64]Answer