Repository navigation
Description
Version
- Fluree DB v4.2.5 (
fluree --version→fluree 4.2.5), release binary for macOS on Apple silicon - macOS 26.6, in-memory server:
fluree server run --memory
Summary
fulltext(?v, "…") over a property listed in f:fullTextDefaults returns a score without a policy. As soon as the request carries a policy identity, the same query returns no rows, also for an identity whose policy allows everything and who can read the value itself. A value typed @fulltext on another property is still scored for that identity. No error is raised.
Steps
A standalone script that reproduces all of this is at the end.
-
Create a ledger and declare the property:
{ "@context": {"ex": "http://example.org/", "f": "https://ns.flur.ee/db#"}, "@graph": [{ "@id": "urn:fluree:repro:main:config:ledger", "@type": "f:LedgerConfig", "@graph": "config", "f:fullTextDefaults": {"@type": "f:FullTextDefaults", "f:defaultLanguage": "en", "f:property": [{"@type": "f:FullTextProperty", "f:target": {"@id": "ex:body"}}]} }] } -
Insert two documents (the same text once as a plain string on
ex:body, once typed@fulltextonex:tagged), an identity and a policy that allows every read:{ "@context": {"ex": "http://example.org/", "f": "https://ns.flur.ee/db#"}, "@graph": [ {"@id": "ex:doc1", "ex:body": "graph databases make relationship queries fast", "ex:tagged": {"@value": "graph databases make relationship queries fast", "@type": "@fulltext"}}, {"@id": "ex:doc2", "ex:body": "time series databases store ordered data", "ex:tagged": {"@value": "time series databases store ordered data", "@type": "@fulltext"}}, {"@id": "ex:reader", "ex:role": "reader", "f:policyClass": [{"@id": "ex:Policy"}]}, {"@id": "ex:allow-all", "@type": ["f:AccessPolicy", "ex:Policy"], "f:action": [{"@id": "f:view"}], "f:allow": true} ] } -
Wait until
GET /v1/fluree/info/repro:mainshowsindex-tequal tot. -
Search, first with no
opts, then with"opts": {"identity": "http://example.org/reader", "default-allow": false}:{ "@context": {"ex": "http://example.org/"}, "select": ["?s", "?score"], "where": [{"@id": "?s", "ex:body": "?v"}, ["bind", "?score", "(fulltext ?v \"graph\")"], ["filter", "(> ?score 0)"]] }
Expected
ex:doc1 with a positive score in both cases. The reader may read ex:body.
Observed
| Request | Result |
|---|---|
ex:body, no policy |
[["ex:doc1", 0.693…]] |
ex:body, as ex:reader |
[] |
plain read of ex:doc1 ex:body, as ex:reader |
the text |
ex:tagged (@fulltext datatype), as ex:reader |
[["ex:doc1", 1.0]] |
Why it matters
Search silently returns nothing for every caller once policies are in use, which reads as "no match". The BM25 graph source is not affected: the same word searched through an index made with POST /bm25/create is found for an identity that may read the text.
Existing reports
None found (searched open and closed issues and pull requests). Possibly the same mechanism, different trigger: #2075 (open) says fulltext() treats a missing single-graph view as nothing to do in a scope of several graphs; a policy-wrapped view may take the same path. That is a guess, not a finding. Pull request #1430 (closed) fixed scoring on configured properties with unindexed data, which is a different case. The v5.0.0-alpha.2 release notes do not mention it.
- Scopes of several graphs: a one-graph witness type, and the readers that still read one graph #2075
- fix: fulltext() scoring on configured predicates with novelty present, plus fulltext and vector scoring perf #1430
Reproduction script
Self-contained: starts a throwaway in-memory server on a loopback port, loads the data, runs the queries, stops the server
#!/usr/bin/env bash
# Usage: FLUREE=/path/to/fluree bash repro.sh
# Needs the Fluree CLI (tested with v4.2.5) on PATH or in $FLUREE, and curl.
# Starts a throwaway in-memory server on a loopback port and stops it on exit.
set -euo pipefail
FLUREE="${FLUREE:-fluree}"
PORT="${PORT:-58090}"
API="http://127.0.0.1:$PORT/v1/fluree"
"$FLUREE" --version
"$FLUREE" server run --memory --listen-addr "127.0.0.1:$PORT" --log-level error >/dev/null 2>&1 &
SERVER=$!
trap 'kill $SERVER 2>/dev/null || true' EXIT
until curl -sf "http://127.0.0.1:$PORT/health" >/dev/null 2>&1; do sleep 0.1; done
# post <path> <body> [content-type] [accept]
post() {
curl -s -X POST "$API/$1" -H "Content-Type: ${3:-application/json}" -H "Accept: ${4:-application/json}" --data-binary "$2"
echo
}
sparql() { post "query/$1" "$2" application/sparql-query application/sparql-results+json; }
# fulltext() over a property declared in f:fullTextDefaults scores nothing when
# the request carries a policy identity, also for an identity allowed to read it.
post create '{"ledger":"repro"}' >/dev/null
post insert/repro:main '{
"@context": {"ex": "http://example.org/", "f": "https://ns.flur.ee/db#"},
"@graph": [{
"@id": "urn:fluree:repro:main:config:ledger", "@type": "f:LedgerConfig", "@graph": "config",
"f:fullTextDefaults": {"@type": "f:FullTextDefaults", "f:defaultLanguage": "en",
"f:property": [{"@type": "f:FullTextProperty", "f:target": {"@id": "ex:body"}}]}
}]
}' >/dev/null
post insert/repro:main '{
"@context": {"ex": "http://example.org/", "f": "https://ns.flur.ee/db#"},
"@graph": [
{"@id": "ex:doc1", "ex:body": "graph databases make relationship queries fast",
"ex:tagged": {"@value": "graph databases make relationship queries fast", "@type": "@fulltext"}},
{"@id": "ex:doc2", "ex:body": "time series databases store ordered data",
"ex:tagged": {"@value": "time series databases store ordered data", "@type": "@fulltext"}},
{"@id": "ex:reader", "ex:role": "reader", "f:policyClass": [{"@id": "ex:Policy"}]},
{"@id": "ex:allow-all", "@type": ["f:AccessPolicy", "ex:Policy"],
"f:action": [{"@id": "f:view"}], "f:allow": true}
]
}' >/dev/null
# Scoring over a declared property needs the first index build; wait for it.
until curl -s "$API/info/repro:main" | grep -q '"index-t":2'; do sleep 0.1; done
search() { # search <property> <opts-json-or-empty>
post query/repro:main "{
\"@context\": {\"ex\": \"http://example.org/\"},
\"select\": [\"?s\", \"?score\"],
\"where\": [{\"@id\": \"?s\", \"ex:$1\": \"?v\"},
[\"bind\", \"?score\", \"(fulltext ?v \\\"graph\\\")\"],
[\"filter\", \"(> ?score 0)\"]]$2
}"
}
IDENTITY=', "opts": {"identity": "http://example.org/reader", "default-allow": false}'
echo "--- declared property, no policy. Expected and observed: doc1 with a score."
search body ''
echo "--- declared property, as the reader (who may read everything). Expected: doc1 with a score."
search body "$IDENTITY"
echo "--- control: the reader can read the value itself."
post query/repro:main '{"@context": {"ex": "http://example.org/"}, "select": ["?v"], "where": {"@id": "ex:doc1", "ex:body": "?v"}, "opts": {"identity": "http://example.org/reader", "default-allow": false}}'
echo "--- control: a value typed @fulltext, as the reader. Observed: doc1 with a score."
search tagged "$IDENTITY"
Activity