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β
| Field | Type | Nullable | Description |
|---|---|---|---|
subject_id | String | No | Subject atom ID |
predicate_id | String | No | Predicate atom ID |
triple_count | Int | No | Number of triples with this subject-predicate pair |
total_position_count | Int | No | Total positions across all triples |
total_market_cap | numeric | No | Combined market cap of all triples |
Relationshipsβ
| Field | Type | Description |
|---|---|---|
subject | atoms | Subject atom entity |
predicate | atoms | Predicate atom entity |
triples | [triples] | All triples with this subject-predicate pair |
triples_aggregate | triples_aggregate | Aggregate 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 })
}
Relatedβ
- Filter by Predicate/Object - Filter triples by predicate and object
- Filter by Subject - Filter triples by subject
- Nested Queries - Complex triple relationship traversal