Parameterized scoring mismatch and subquery error
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
Direzione di ricerca
Start in postgres/src/score.rs, especially score_support(), combine_constant_queries(), and the caller around the cited lines. Reproduce both cases with the SQL in the issue, then trace parameter handling and scorer context propagation; done means parameterized and literal queries produce matching scores and the subquery aggregate no longer raises the context error.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Ran into a couple issues with using lead for running tests versus actual hosted tin.
Environment: Lead 1.0.3, commit bd95c7e, PostgreSQL 18.6.
Using parameters instead of identical literals changes relevance scores.
Reproduction:
CREATE TEMP TABLE lead_score_repro (
id integer PRIMARY KEY,
title text NOT NULL
);
INSERT INTO lead_score_repro VALUES
(1, 'lorem ipsum'),
(2, 'lorem ipsun');
CREATE INDEX ON lead_score_repro USING tin (title);
ANALYZE lead_score_repro;
PREPARE lead_ranked(text, text) AS
SELECT id, tin.score(ctid) AS score
FROM lead_score_repro
WHERE title ==> $1 AND title ==> $2
ORDER BY id;
EXECUTE lead_ranked(
'lorem^4',
'(ipsum^4 OR ipsum~1^1.4 OR ipsum*^2)'
);
SELECT id, tin.score(ctid) AS score
FROM lead_score_repro
WHERE title ==> 'lorem^4'
AND title ==> '(ipsum^4 OR ipsum~1^1.4 OR ipsum*^2)'
ORDER BY id;
This gives the following:
| Query | ID 1 score | ID 2 score |
|---|---|---|
| Parameters | 0.72928625 | 0.72928625 |
| Literals | 4.472281 | 0.72928625 |
I believe this is due to the first-query fallback in score_support() that causes this. combine_constant_queries() requires Const nodes and returns None for parameters. The caller then uses first_query, discarding the remaining expressions from scoring:
let combined_query = combine_constant_queries(&same_expression)
.unwrap_or_else(|| pg_sys::copyObjectImpl(first_query.cast()).cast());
In EXPLAIN (VERBOSE, COSTS OFF), I see score_bound(title, $1, ...) for the parameterized query. For the literal query, I see both search expressions in the scorer's query argument.
Aggregating scores through a subquery raises a scoring-context error
CREATE TEMP TABLE lead_score_repro (
id integer PRIMARY KEY,
title text NOT NULL
);
INSERT INTO lead_score_repro VALUES
(1, 'lorem ipsum'),
(2, 'lorem ipsun');
CREATE INDEX ON lead_score_repro USING tin (title);
ANALYZE lead_score_repro;
-- Succeeds.
SELECT max(tin.score(ctid)) AS score
FROM lead_score_repro
WHERE title ==> 'lorem^4';
-- Fails.
SELECT max(score) AS score
FROM (
SELECT tin.score(ctid) AS score
FROM lead_score_repro
WHERE title ==> 'lorem^4'
) AS matches;
For the direct aggregate, I get 0.72928625. For the subquery aggregate, I get:
ERROR: tin.score() requires a tin index scan and cannot be used in this query context
SQLSTATE: XX000
- Lingua principale
- Rust
- Stelle
- 160
- Fork
- 10
- Merge medio
- 18h 42m
- PR unite (30g)
- 16
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
V1 manifest lists written by Java lose added/existing/deleted file countsForse già presa @kacper-li-airspace-intelligence l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
apache/iceberg-rust#3445 ·
I maintainer di solito rispondono entro 4 giorni
-
Slack integration: links on self-hosted domains never unfurl (parseCapShareUrl only accepts cap.so / cap.link)Forse già presa @mangeshraut712 l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
CapSoftware/Cap#2546 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 1 giorno
-
area::tern-sync kind::cleanup triage::ready
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno