Skip to content

BM25 indexes can't index documents whose text is in a named graph #2243

Open

Description

@bplatz

Problem

A BM25 indexing query whose documents live in a named graph builds an empty index, and nothing says so. The where matches, but a document's text comes from the select hydration, and the indexing path formats results against the default graph: execute_bm25_indexing_query in fluree-db-api/src/graph_source/bm25.rs calls result.to_jsonld_async(ledger.as_graph_db_ref(0)). The hydrated document has none of the selected properties, so the builder finds no text and skips it.

execute_vector_indexing_query in vector.rs runs and formats the same way, so vector indexes should have the same gap. That hasn't been run.

Repro

PREFIX ex: <http://example.org/>
INSERT DATA { GRAPH <http://example.org/g> { ex:g1 a ex:Doc ; ex:title "g1 report" } }
{
  "@context": {"ex": "http://example.org/"},
  "where": [["graph", "ex:g", {"@id": "?x", "@type": "ex:Doc", "ex:title": "?title"}]],
  "select": {"?x": ["@id", "ex:title"]}
}

create_full_text_index with that query gives an index with no documents. Writing the title to the default graph, and only ex:g1 a ex:Doc to <g>, gets ex:g1 indexed.

Options

  1. Let the index config name the graph its query reads, then run and format the query against that graph.
  2. Hydrate each document from the graph its where matched it in.
  3. Either way, warn when matched documents come out with no text, so that an empty index isn't silent.

Activity

  1. added
    bug
    P2
    area:query
    on Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2area:querybugfull text search

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions