Skip to main content

Ontology and Data access APIs

Introduction

The Fusion Semantic SQL API is the low level way to query data, it uses a Semantic SQL dialect which makes it much simpler to write joins as it leverages the datamodel. It can perform all that is possible with the Ontology API or the Entity API but might be more complex to use and require results to be parsed.

The Ontology API is the way one can programmatically explore the data model (Concepts and relations)

The Entity API programmatic "traversal" of data e.g. moving from one record to another within a script - no Semantic SQL required.

Fusion Semantic SQL API

fusionSQL() -➝ returns JSON

fires a low level Fusion SQL API, for the full documentation see..

Ontology API

This allows for an easy programmatic exploration of the datamodel and easy

getConcepts( ... tbd)

getRelations([from],[to],[options])

  • from: optional, this is the starting concept. If unspecified then * is assumed
  • to: optional, this is the target concept, if unspecified * is assumed
  • Options:
    • "one to many" - just returns relations which are 1 to many
    • "manyTomany" - just return relations which are many to many.
    • Future consideration
      • "mapped internally" - just returns relations which are mapped to the Octostar default internal tables database
      • "mapped externally" - just returns relations which are mapped to other tables - typically these are those mapped to big deployment specific tables

Entity API

This allows easy entity to entity navigation and full access to the entity content in an easy, type parsed way.

myentity = new Entity(ID, [opt concept]). This instantiates the entity. Could be a lazy instantiation without a fetching of the record

myentity.getAttribute(attributename) --> gets you the value, might cause the entity to actually load in memory

myentity.getRelations(opt RelationNames[], opt direction) -➝ returns an array with the relations involving the entity. Options

    • direction = outgoing | ingoing to select just one direction, otherwise it will return both.

myentity.getRelationCounts(opt RelationNames[]) -➝ gets the counts for the specific relations.

myentity.getRelationIDs(relationname[], optional limit, optional sortbySQL) -➝ gets the IDs for the entity connected to myentity via one of the relations.

  • limit, if not set then 10000
  • sortbySQL determins the order of the results, must be a valid piece of Fusion SQL

myentity.getRelatedEntities(relationname[], optional limit, optional fetchfields, optional sortbySQL) -➝ sameAsAbove but returns an array of entities

  • limit if not set then 10000
  • fetchfield -➝I F "true" then - hidrates the whole record else array of fields - only fetches those (might be much better for columnar dbs)

Entity giovanni = OntologyAPI.getEntity{ entity_id: '923845792875', entity_type: 'person"})

in JS now:

const giovanni : Entity = await OntologyAPI.getEntity( { entity_id: '923845792875', entity_type: 'person"})

Entity[] cars[] = giovanni.getRelatedEntities("ownCar",10000, 'label,displacement,year', 'year')

Entity[] cars[] = giovanni.getRelatedEntities("ownCar",10000);

for car in cars = print(car.label+car.displacement+car.year)