7.4 ai.score — the per-row rerank
MATCH (me:AssistantUser)-[:TRACKS]->(n:NewsItem)RETURN n.title, n.urlORDER BY ai.score(n, 'relevance to my Series A funding round') DESCLIMIT 5Means: “rank the fetched news by how well each fits, and give me the top five” — the highest-value retrieval lever, a learned relevance sort where no orderable property exists.
How it executes:
- Fetch as above.
- Judge — the same batched 0..1 scoring as
ai.relevant(the two share one judgment; a query using both scores once and both filters and ranks off it). Every row is kept and its score stamped under the internalai_scoreproperty. - Rewrite & run. Neo4j has no
ai.scorefunction, so the executor rewrites the call in the executed query tocoalesce(n.ai_score, 0.0)(0.0 for any row that wasn’t scored), andORDER BY … DESC LIMIT kranks and truncates against the stamp.
The idiomatic filter-then-rank: WHERE ai.relevant(n, '…') … ORDER BY ai.score(n, '…') DESC LIMIT k —
narrow to the relevant, then order the survivors by fit.

