Skip to content

Query

Queries retrieve data pre-computed during mutations.

See Core Concepts for background.

StructureCreated DuringAccessed By
EdgeStateMutationGET
EdgeIndexMutationSCAN
EdgeCounterMutationCOUNT

You specify the query type and index. Each query accesses structures prepared at write time.

Retrieves edge state by source and target.

Use case: “Has this user viewed this product?”

Processing:

  1. Construct EdgeState key from source and target
  2. Return edge state

MGet:

  • Multiple source or target IDs → multi-get
  • Max 25 edges per request
  • Patterns: 1 source with N targets, or M sources with 1 target

Scans edges using a pre-computed index with range filtering and pagination.

Use case: “Recent products viewed by this user”

Processing:

  1. Construct EdgeIndex key prefix from source, table, direction, index
  2. Apply range filters
  3. Scan index entries
  4. Apply optional filters
  5. Apply pagination (limit, offset)
  6. Return matching edges

Index Requirement:

  • Must specify which index to use
  • Index must be defined in schema

Returns the number of edges for a source node.

Use case: “How many products has this user viewed?”

Processing:

  1. Construct EdgeCounter key from source, table, direction
  2. Return pre-computed counter
flowchart TD
    Request([Query Request]) --> Route{Query Type}
    Route -->|GET| GetQuery[Get Query]
    Route -->|SCAN| ScanQuery[Scan Query]
    Route -->|COUNT| CountQuery[Count Query]
    GetQuery --> EdgeState[Read EdgeState]
    ScanQuery --> EdgeIndex[Read EdgeIndex]
    CountQuery --> EdgeCounter[Read EdgeCounter]
    EdgeState --> Response([Response])
    EdgeIndex --> Response
    EdgeCounter --> Response

SCAN queries can specify ranges to filter at storage level.

ConceptDescription
Explicit IndexMust specify which index
Operatorseq, gt, lt, between set scan boundaries
Index OrderRanges applied in field order
Sort DirectionOperator meaning depends on ASC/DESC
TypeLevelUses IndexPerformance
RangeStorageYesFast
FilterApplicationNoAfter retrieval
ParameterDescription
offsetEncoded starting position
limitMax results (25 recommended)
hasNextMore results available
DirectionDescriptionExample
OUTOutgoing edgesProducts a user liked
INIncoming edgesUsers who liked a product

Separate indexes and counters maintained for each direction.

Client → Server → Engine → Storage → Response
  1. Client: Query via REST API
  2. Server: Validate request
  3. Engine: Construct key, retrieve data
  4. Storage: Return EdgeState/EdgeIndex/EdgeCounter
  5. Response: Return to client