Choose How to Load and Query Data
Use this path after Quickstart to choose between object writes, columnar loading, indexed cohorts and Cypher. All operate on the current property graph; they do not automatically append immutable temporal history or execute ontology rules. The existing Components, Interfaces, and Applications diagram shows these interfaces and their explicit handoffs; a loading/query tutorial does not need a second component map.
Choose an interface
Task |
Start with |
Check first |
|---|---|---|
Incrementally create or replace a few entities |
|
Entity IDs, complete replacement payloads, and required transaction scope (The Property Graph, Storage Backends). |
Load a table of entities/relationships |
|
Structured versus serialized input, explicit property columns, append-only edges and index policy (Load Arrow and Polars Data). |
Fetch known IDs |
|
No property index is required for an ID lookup. |
Select an exact/range cohort |
|
Property indexes must exist and be fresh (Property-Graph Filtering and Indexes). |
Match patterns, join results, aggregate or mutate |
|
Supported clauses, parameter names and atomicity boundaries (Query and Mutate with Cypher, Cypher Queries). |
An index is not required for every Cypher predicate: eligible indexes select candidates, and remaining predicates are evaluated against them. A successful query does not prove index use. Conversely, direct property-index helpers are not a replacement for an unindexed scan; create the index before relying on them.
An indexed cohort, with expected IDs
Standalone runnable example. Requires gestaltdb[lmdb]. Property-index
creation builds entries for existing records and maintains subsequent writes.
Labels and relationship types are indexed automatically.
Standalone example. Choose the capability-qualified installation tab below.
Exact/range property indexing is portable across these backends and supported codecs.
1python -m pip install "gestaltdb[lmdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='lmdb', serializer='json') as graph:
6 graph.put_nodes([
7 Node("p1", labels=["Protein"], properties={"score": 0.9}),
8 Node("p2", labels=["Protein"], properties={"score": 0.4}),
9 Node("d1", labels=["Drug"], properties={"score": 0.95}),
10 ])
11 graph.create_node_property_index("score")
12 cohort = graph.nodes_by_label_property_range("Protein", "score", 0.8, None)
13 assert {node.get_id for node in cohort} == {"p1"}
14 ids = list(graph.iter_node_ids_by_label_property_range("Protein", "score", 0.8, None))
15 assert ids == [b"p1"]
1python -m pip install "gestaltdb[lmdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='lmdb', serializer='pickle') as graph:
6 graph.put_nodes([
7 Node("p1", labels=["Protein"], properties={"score": 0.9}),
8 Node("p2", labels=["Protein"], properties={"score": 0.4}),
9 Node("d1", labels=["Drug"], properties={"score": 0.95}),
10 ])
11 graph.create_node_property_index("score")
12 cohort = graph.nodes_by_label_property_range("Protein", "score", 0.8, None)
13 assert {node.get_id for node in cohort} == {"p1"}
14 ids = list(graph.iter_node_ids_by_label_property_range("Protein", "score", 0.8, None))
15 assert ids == [b"p1"]
1python -m pip install "gestaltdb[lmdb,msgpack]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='lmdb', serializer='messagepack') as graph:
6 graph.put_nodes([
7 Node("p1", labels=["Protein"], properties={"score": 0.9}),
8 Node("p2", labels=["Protein"], properties={"score": 0.4}),
9 Node("d1", labels=["Drug"], properties={"score": 0.95}),
10 ])
11 graph.create_node_property_index("score")
12 cohort = graph.nodes_by_label_property_range("Protein", "score", 0.8, None)
13 assert {node.get_id for node in cohort} == {"p1"}
14 ids = list(graph.iter_node_ids_by_label_property_range("Protein", "score", 0.8, None))
15 assert ids == [b"p1"]
1python -m pip install "gestaltdb[lmdb,protobuf]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='lmdb', serializer='protobuf') as graph:
6 graph.put_nodes([
7 Node("p1", labels=["Protein"], properties={"score": 0.9}),
8 Node("p2", labels=["Protein"], properties={"score": 0.4}),
9 Node("d1", labels=["Drug"], properties={"score": 0.95}),
10 ])
11 graph.create_node_property_index("score")
12 cohort = graph.nodes_by_label_property_range("Protein", "score", 0.8, None)
13 assert {node.get_id for node in cohort} == {"p1"}
14 ids = list(graph.iter_node_ids_by_label_property_range("Protein", "score", 0.8, None))
15 assert ids == [b"p1"]
1python -m pip install "gestaltdb[leveldb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='leveldb', serializer='json') as graph:
6 graph.put_nodes([
7 Node("p1", labels=["Protein"], properties={"score": 0.9}),
8 Node("p2", labels=["Protein"], properties={"score": 0.4}),
9 Node("d1", labels=["Drug"], properties={"score": 0.95}),
10 ])
11 graph.create_node_property_index("score")
12 cohort = graph.nodes_by_label_property_range("Protein", "score", 0.8, None)
13 assert {node.get_id for node in cohort} == {"p1"}
14 ids = list(graph.iter_node_ids_by_label_property_range("Protein", "score", 0.8, None))
15 assert ids == [b"p1"]
1python -m pip install "gestaltdb[leveldb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='leveldb', serializer='pickle') as graph:
6 graph.put_nodes([
7 Node("p1", labels=["Protein"], properties={"score": 0.9}),
8 Node("p2", labels=["Protein"], properties={"score": 0.4}),
9 Node("d1", labels=["Drug"], properties={"score": 0.95}),
10 ])
11 graph.create_node_property_index("score")
12 cohort = graph.nodes_by_label_property_range("Protein", "score", 0.8, None)
13 assert {node.get_id for node in cohort} == {"p1"}
14 ids = list(graph.iter_node_ids_by_label_property_range("Protein", "score", 0.8, None))
15 assert ids == [b"p1"]
1python -m pip install "gestaltdb[leveldb,msgpack]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='leveldb', serializer='messagepack') as graph:
6 graph.put_nodes([
7 Node("p1", labels=["Protein"], properties={"score": 0.9}),
8 Node("p2", labels=["Protein"], properties={"score": 0.4}),
9 Node("d1", labels=["Drug"], properties={"score": 0.95}),
10 ])
11 graph.create_node_property_index("score")
12 cohort = graph.nodes_by_label_property_range("Protein", "score", 0.8, None)
13 assert {node.get_id for node in cohort} == {"p1"}
14 ids = list(graph.iter_node_ids_by_label_property_range("Protein", "score", 0.8, None))
15 assert ids == [b"p1"]
1python -m pip install "gestaltdb[leveldb,protobuf]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='leveldb', serializer='protobuf') as graph:
6 graph.put_nodes([
7 Node("p1", labels=["Protein"], properties={"score": 0.9}),
8 Node("p2", labels=["Protein"], properties={"score": 0.4}),
9 Node("d1", labels=["Drug"], properties={"score": 0.95}),
10 ])
11 graph.create_node_property_index("score")
12 cohort = graph.nodes_by_label_property_range("Protein", "score", 0.8, None)
13 assert {node.get_id for node in cohort} == {"p1"}
14 ids = list(graph.iter_node_ids_by_label_property_range("Protein", "score", 0.8, None))
15 assert ids == [b"p1"]
1python -m pip install "gestaltdb[rocksdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='pyrex', serializer='json') as graph:
6 graph.put_nodes([
7 Node("p1", labels=["Protein"], properties={"score": 0.9}),
8 Node("p2", labels=["Protein"], properties={"score": 0.4}),
9 Node("d1", labels=["Drug"], properties={"score": 0.95}),
10 ])
11 graph.create_node_property_index("score")
12 cohort = graph.nodes_by_label_property_range("Protein", "score", 0.8, None)
13 assert {node.get_id for node in cohort} == {"p1"}
14 ids = list(graph.iter_node_ids_by_label_property_range("Protein", "score", 0.8, None))
15 assert ids == [b"p1"]
1python -m pip install "gestaltdb[rocksdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='pyrex', serializer='pickle') as graph:
6 graph.put_nodes([
7 Node("p1", labels=["Protein"], properties={"score": 0.9}),
8 Node("p2", labels=["Protein"], properties={"score": 0.4}),
9 Node("d1", labels=["Drug"], properties={"score": 0.95}),
10 ])
11 graph.create_node_property_index("score")
12 cohort = graph.nodes_by_label_property_range("Protein", "score", 0.8, None)
13 assert {node.get_id for node in cohort} == {"p1"}
14 ids = list(graph.iter_node_ids_by_label_property_range("Protein", "score", 0.8, None))
15 assert ids == [b"p1"]
1python -m pip install "gestaltdb[msgpack,rocksdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='pyrex', serializer='messagepack') as graph:
6 graph.put_nodes([
7 Node("p1", labels=["Protein"], properties={"score": 0.9}),
8 Node("p2", labels=["Protein"], properties={"score": 0.4}),
9 Node("d1", labels=["Drug"], properties={"score": 0.95}),
10 ])
11 graph.create_node_property_index("score")
12 cohort = graph.nodes_by_label_property_range("Protein", "score", 0.8, None)
13 assert {node.get_id for node in cohort} == {"p1"}
14 ids = list(graph.iter_node_ids_by_label_property_range("Protein", "score", 0.8, None))
15 assert ids == [b"p1"]
1python -m pip install "gestaltdb[protobuf,rocksdb]"
1from tempfile import TemporaryDirectory
2from gestaltdb.graphdb import GraphDB, Node
3
4with TemporaryDirectory() as root:
5 with GraphDB.create(f"{root}/graph", backend='pyrex', serializer='protobuf') as graph:
6 graph.put_nodes([
7 Node("p1", labels=["Protein"], properties={"score": 0.9}),
8 Node("p2", labels=["Protein"], properties={"score": 0.4}),
9 Node("d1", labels=["Drug"], properties={"score": 0.95}),
10 ])
11 graph.create_node_property_index("score")
12 cohort = graph.nodes_by_label_property_range("Protein", "score", 0.8, None)
13 assert {node.get_id for node in cohort} == {"p1"}
14 ids = list(graph.iter_node_ids_by_label_property_range("Protein", "score", 0.8, None))
15 assert ids == [b"p1"]
The label/property helper selects a Protein cohort, not every high-scoring
entity. These are label-plus-one-property indexes, not arbitrary multi-property
composite indexes. Ranges are inclusive by default; use include_end=False
for an exclusive upper bound and None for an unbounded endpoint. Keys and
ID iterators return bytes, while decoded entities expose string get_id values.
See Property-Graph Filtering and Indexes for the full exact/range/ID/count map and the portable
511-byte encoded-index-key limit.
Freshness is part of the workflow
Object writes maintain configured current indexes. Columnar loading chooses an index policy: maintain during writes, defer and explicitly rebuild, or defer and rebuild before returning. A stale-family error is a signal to complete the documented rebuild, not permission to ignore freshness or read raw index keys. The Load Arrow and Polars Data examples show the policy explicitly.
For a multi-step current-graph selection that must observe one state, use a supported current read view (Storage Backends). A read-only repository alone is not a pinned snapshot. Temporal-history indexes and sampler arrays have separate freshness/identity rules.
From cohort selection to sampling
An indexed cohort chooses starting entities. It does not restrict the graph
visited at later hops. If every hop must stay within a property-defined graph,
build a snapshot with node_filter / edge_filter. The end-to-end workflow
is in Property-Graph Filtering and Indexes; draw policies and ID conversions are in
Graph sampling API and policy reference.
Next steps
Load Arrow and Polars Data: runnable Arrow, Polars and pre-serialized input workflows.
Query and Mutate with Cypher: pattern reads, aggregation and writes with expected rows.
Cypher Queries: detailed syntax, temporal qualifiers, constraints and procedures.
Performance and Benchmarks: measure writes, index rebuilding and reads separately.