Skip to content

fix(scoring): a Solr operator is not an acronym - #543

Merged
aborruso merged 3 commits into
mainfrom
fix/boolean-operators-not-acronyms
Sep 6, 2026
Merged

fix(scoring): a Solr operator is not an acronym#543
aborruso merged 3 commits into
mainfrom
fix/boolean-operators-not-acronyms

Conversation

@aborruso

@aborruso aborruso commented Sep 6, 2026

Copy link
Copy Markdown
Member

Found testing the local MCP client after #542: ckan_find_relevant_datasets on aria OR acqua reported "terms": ["aria","or","acqua"].

The all-caps exception added in #536 — so that UN population keeps its UN — also let Solr's own operators through. OR is all-caps by convention, so it survived the stopword list and became a scoring term: a title carrying one of the two real terms scored 4 × 1/3 = 1.3 instead of 4 × 1/2 = 2. Result counts are unaffected (they come from Solr); the local ranking of every boolean query was diluted.

AND, OR and NOT are now dropped before the acronym rule. Lowercase or was already a stopword and stays one. Test added; 544 tests; the cross-tool smoke case passes.

Verified live on dati.comune.milano.it: terms ["aria","acqua"], title share 2 instead of 1.3.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MEpSWpAwuMaGkfnMpQdqK2

The all-caps exception added in #536 so that `UN population` keeps its `UN` also
let `OR`, `AND` and `NOT` through: `aria OR acqua` scored on three terms, and a
title carrying one of them got 4 × 1/3 instead of 4 × 1/2. Found testing the
local MCP client after the merge — the term list in the response read
["aria","or","acqua"].

Solr's boolean keywords are dropped before the acronym rule. Lowercase `or`
was already a stopword and stays one.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MEpSWpAwuMaGkfnMpQdqK2
@greptile-apps

greptile-apps Bot commented Sep 6, 2026

Copy link
Copy Markdown

Greptile Summary

This PR corrects local relevance scoring for Solr boolean queries and improves quoted-phrase parsing.

  • Excludes bare AND, OR, and NOT operators from scoring terms.
  • Preserves operators used as literals inside quoted phrases.
  • Handles escaped quotes within phrases and adds focused regression coverage.

Important Files Changed

Filename Overview
src/tools/package.ts Updates query-term extraction to distinguish bare Solr operators from quoted literals and correctly skip escaped characters while locating phrase boundaries.
tests/unit/package-scoring.test.ts Adds regression coverage for bare operators, quoted operators, and escaped quotes inside phrases.

Reviews (3): Last reviewed commit: "fix(scoring): an escaped quote does not ..." | Re-trigger Greptile

Comment thread src/tools/package.ts Outdated
Review finding on #543: `"OR"` in double quotes is a literal search term to Solr,
and dropping every OR token after tokenisation had discarded the quotes left such
a query with no terms to score on. It had never scored — before #536 the `or`
stopword took it — so this is a step past the regression, not just its repair.

Quoted tokens are collected before filtering; an operator is dropped only when
it is bare. Test added; 545 tests.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MEpSWpAwuMaGkfnMpQdqK2
Comment thread src/tools/package.ts Outdated
Comment thread tests/unit/package-scoring.test.ts
Review finding: the quoted-fragment regex stopped at a backslash-escaped quote,
so in `"OR\" AND"` only `OR` counted as quoted and the literal `AND` was dropped
as syntax. The regex now skips escaped characters inside the phrase. Test added.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MEpSWpAwuMaGkfnMpQdqK2
@aborruso
aborruso merged commit 8286339 into main Sep 6, 2026
7 checks passed
@aborruso
aborruso deleted the fix/boolean-operators-not-acronyms branch September 6, 2026 07:22
@aborruso aborruso mentioned this pull request Sep 6, 2026
aborruso added a commit that referenced this pull request Sep 6, 2026
Ships #542 (migrated-portal notice), #543 (boolean operators are not scored
terms), #544 (full-coverage candidate pass and stemming) and #545 (smoke cases
for the strict pass).

Version bumped in package.json, package-lock.json, manifest.json, server.json
(both fields), src/server.ts and src/worker.ts. No tools added or removed, so
/health stays at 20.

Release gate 16/16, 550 tests.


Claude-Session: https://claude.ai/code/session_01MEpSWpAwuMaGkfnMpQdqK2

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant