Skip to main content

Subject Predicates

Query aggregated subject-predicate pairs across the knowledge graph. Each record represents a unique (subject, predicate) combination with aggregate stats across all triples sharing that pair.

Query Structure​

query GetSubjectPredicates($subjectId: String!, $limit: Int!) {
subject_predicates(
where: { subject_id: { _eq: $subjectId } }
order_by: { triple_count: desc }
limit: $limit
) {
subject_id
predicate_id
triple_count
total_position_count
total_market_cap
subject {
label
image
}
predicate {
label
}
triples(limit: 5) {
term_id
object {
label
}
}
}
}

Response Fields​

FieldTypeNullableDescription
subject_idStringNoSubject atom ID
predicate_idStringNoPredicate atom ID
triple_countIntNoNumber of triples with this subject-predicate pair
total_position_countIntNoTotal positions across all triples
total_market_capnumericNoCombined market cap of all triples

Relationships​

FieldTypeDescription
subjectatomsSubject atom entity
predicateatomsPredicate atom entity
triples[triples]All triples with this subject-predicate pair
triples_aggregatetriples_aggregateAggregate over triples

Primary Key Lookup​

query GetSubjectPredicate($subjectId: String!, $predicateId: String!) {
subject_predicates_by_pk(
subject_id: $subjectId
predicate_id: $predicateId
) {
triple_count
total_position_count
total_market_cap
triples {
term_id
object { label }
}
}
}

Interactive Example​

Query

query GetSubjectPredicates($subjectId: String!, $limit: Int!) {
  subject_predicates(
    where: { subject_id: { _eq: $subjectId } }
    order_by: { triple_count: desc }
    limit: $limit
  ) {
    predicate_id
    triple_count
    total_position_count
    total_market_cap
    predicate { label }
    triples(limit: 3) {
      object { label }
    }
  }
}

Variables

Click "Run Query" to execute the GraphQL query and see results

Use Cases​

Knowledge Graph Exploration​

Find all predicates used with a subject and their objects:

async function exploreEntity(subjectId: string) {
const query = `
query ExploreEntity($subjectId: String!) {
subject_predicates(
where: { subject_id: { _eq: $subjectId } }
order_by: { total_market_cap: desc }
) {
predicate { label }
triple_count
total_market_cap
triples(order_by: { term: { total_market_cap: desc } }, limit: 5) {
object { label image }
}
}
}
`

return client.request(query, { subjectId })
}