Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions lightrag/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -907,14 +907,17 @@ async def get_knowledge_graph(
its graph view at the same cutoff. Every other backend orders its ``*``
ranking on the label; do not copy the deviation into a new one.

**Known approximation -- OpenSearchGraphStorage** applies the rule, but
only to the candidates its degree aggregations surfaced, and that set is
approximate: the two endpoint aggregations are each capped at
``max_nodes``, so an entity whose in- and out-degree both fall outside
their respective top-N never reaches the ranking however high its
undirected degree is, and terms aggregations are count-approximate
across shards. Tracked in issue #3613; it needs a storage-shape change,
not an ordering one.
**OpenSearchGraphStorage** ranks from a single terms aggregation over
an ``endpoints`` field carrying both ids of each edge document, so one
bucket per entity holds its true undirected degree and the candidate
set is the global top by degree. This replaced a union of two
per-field aggregations, each separately capped, which omitted any
entity whose in- and out-degree both fell outside their respective
top-N however high its total degree was (issue #3613). An index
predating the ``endpoints`` backfill keeps the old union until startup
completes it, and on a multi-shard index the merged bucket counts stay
subject to the usual terms-aggregation error, which that backend logs
when the reported bound is non-zero.

This constrains WHICH nodes survive truncation, not the order of
:class:`KnowledgeGraph.nodes` in the response — implementations
Expand Down
Loading
Loading