Query Entities

Observable: Query Entities

User Intent

"I want to query extracted entities (people, organizations, topics) from my knowledge graph"

Operation

  • SDK Method: graphlit.queryObservables()

  • GraphQL: queryObservables query

  • Entity Type: Observable

  • Common Use Cases: Knowledge graph queries, entity search, relationship discovery, semantic network exploration

TypeScript (Canonical)

import { Graphlit } from 'graphlit-client';
import { ObservableTypes } from 'graphlit-client/dist/generated/graphql-types';

const graphlit = new Graphlit();

// Query all people and organizations
const observablesResponse = await graphlit.queryObservables({
  observableTypes: [
    ObservableTypes.Person,
    ObservableTypes.Organization
  ]
});

console.log(`Found ${observablesResponse.observables.results.length} entities`);

observablesResponse.observables.results.forEach(entity => {
  console.log(`${entity.type}: ${entity.name}`);
  if (entity.description) {
    console.log(`  Description: ${entity.description}`);
  }
});

// Search for specific entity
const searchResponse = await graphlit.queryObservables({
  observableTypes: [ObservableTypes.Person],
  search: 'John Smith'
});

// Query entities from specific content
const contentEntities = await graphlit.queryObservables({
  contents: [{ id: contentId }]
});

console.log(`Entities in content: ${contentEntities.observables.results.length}`);

Query entities (snake_case)

response = await graphlit.queryObservables( filter=ObservableFilterInput( observable_types=[ ObservableTypes.PERSON, ObservableTypes.ORGANIZATION ] ) )

for entity in response.observables.results: print(f"{entity.type}: {entity.name}")

Search for specific entity

search_response = await graphlit.queryObservables( filter=ObservableFilterInput( observable_types=[ObservableTypes.PERSON], search="John Smith" ) )

Parameters

ObservableFilter (Optional)

  • observableTypes (ObservableTypes[]): Types to query

    • PERSON - People, individuals

    • ORGANIZATION - Companies, institutions

    • PLACE - Locations, addresses

    • PRODUCT - Products, services

    • EVENT - Events, occurrences

    • TOPIC - Concepts, themes

    • Custom types (if defined in extraction workflow)

  • search (string): Search query for entity names

  • contents (EntityReferenceFilter[]): Filter by source content

  • limit (int): Max results (default: 100)

  • offset (int): Pagination offset

Response

Developer Hints

Entities Must Be Extracted First

Important: You must use an extraction workflow during content ingestion to create entities.

Filter by Entity Type

Search for Entities

Entity Occurrence Count

Variations

1. Query All Entities

Get all extracted entities:

2. Query People Only

Find all people:

3. Search for Specific Entity

Find specific entity by name:

4. Query Entities from Specific Content

Get entities from specific document:

5. Top Mentioned Entities

Get most frequently mentioned:

6. Custom Entity Types

Query custom extraction types:

Common Issues

Issue: No entities returned Solution: Ensure content was ingested with extraction workflow. Check workflow has entity extraction configured.

Issue: Wrong entity types extracted Solution: Specify observableTypes in extraction workflow. Use customTypes for domain-specific entities.

Issue: Entity names are incomplete Solution: Use better extraction model (Claude Sonnet 3.7, GPT-4o). Check source content quality.

Issue: Too many irrelevant entities Solution: Filter by observableTypes. Use search parameter to narrow results.

Issue: Entity occurrence count seems wrong Solution: Count reflects mentions across all content. Entity may be mentioned multiple times per document.

Production Example

Entity discovery pipeline:

Entity search interface:

Last updated

Was this helpful?