Skip to content

Add per-query field boost directives to lexical search#2472

Draft
Mbeaulne wants to merge 1 commit into
masterfrom
06-29-query_weight_change
Draft

Add per-query field boost directives to lexical search#2472
Mbeaulne wants to merge 1 commit into
masterfrom
06-29-query_weight_change

Conversation

@Mbeaulne

@Mbeaulne Mbeaulne commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Description

Adds support for per-query field boost directives in the lexical search syntax. Users can now include bracket expressions (e.g., upload [metadata^20] or upload [metadata+10, title-5]) in their search queries to dynamically adjust how much weight individual fields contribute to scoring for that specific query.

Supported operator formats within [...] blocks:

  • ^N — multiply the field's base weight by N
  • =N — set the field weight to an absolute value
  • + / ++ / +++ — increment weight by the number of + characters
  • - / -- / --- — decrement weight by the number of - characters
  • +N / -N — add or subtract a numeric value

Field aliases are supported (e.g., titlename, descdescription, implimplementation, input/outputio, metametadata).

Phrase bonuses are scaled proportionally to the adjusted field weights, keeping scoring consistent. Boost blocks are stripped from the query text before token parsing so they do not interfere with term matching.

Related Issue and Pull requests

Type of Change

  • Bug fix
  • New feature
  • Improvement
  • Cleanup/Refactor
  • Breaking change
  • Documentation update

Checklist

  • I have tested this does not break current pipelines / runs functionality
  • I have tested the changes on staging

Screenshots (if applicable)

Test Instructions

  1. Run the test suite with npm test (or equivalent) and confirm the new "supports per-query field boosts in bracket directives" test passes alongside existing lexical search tests.
  2. Perform a manual search using a query like upload [metadata^20] and verify that results with matching metadata rank above results that only match on name/title.
  3. Confirm that the bracket directive text itself does not appear as a matched token or affect unrelated results.

Additional Comments

The field weight overrides are scoped entirely to the parsed query and do not mutate the global FIELD_WEIGHTS constant.

@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown

🎩 Preview

A preview build has been created at: 06-29-query_weight_change/66f76ec

Copy link
Copy Markdown
Collaborator Author

@Mbeaulne Mbeaulne changed the title Query weight change Add per-query field boost directives to lexical search Jun 29, 2026
@Mbeaulne Mbeaulne force-pushed the 06-29-fix_production_slowness branch 2 times, most recently from cdd3ff0 to 23eb21c Compare June 29, 2026 18:14
@Mbeaulne Mbeaulne force-pushed the 06-29-query_weight_change branch 2 times, most recently from 98ec0d9 to d212ea0 Compare June 29, 2026 18:20
@Mbeaulne Mbeaulne force-pushed the 06-29-fix_production_slowness branch 2 times, most recently from 84aa8ca to dbf3739 Compare June 29, 2026 18:38
@Mbeaulne Mbeaulne force-pushed the 06-29-query_weight_change branch from d212ea0 to 5a0dd13 Compare June 29, 2026 18:38
@Mbeaulne Mbeaulne changed the base branch from 06-29-fix_production_slowness to graphite-base/2472 June 29, 2026 19:41
@Mbeaulne Mbeaulne force-pushed the 06-29-query_weight_change branch from 5a0dd13 to f0f3c5f Compare July 8, 2026 12:43
@Mbeaulne Mbeaulne force-pushed the graphite-base/2472 branch from dbf3739 to f306696 Compare July 8, 2026 12:43
@Mbeaulne Mbeaulne changed the base branch from graphite-base/2472 to 06-29-fix_production_slowness July 8, 2026 12:43
@Mbeaulne Mbeaulne changed the base branch from 06-29-fix_production_slowness to graphite-base/2472 July 8, 2026 16:41
@Mbeaulne Mbeaulne force-pushed the graphite-base/2472 branch from f306696 to 8674be9 Compare July 8, 2026 16:46
@Mbeaulne Mbeaulne force-pushed the 06-29-query_weight_change branch from f0f3c5f to f48e1e3 Compare July 8, 2026 16:46
@graphite-app graphite-app Bot changed the base branch from graphite-base/2472 to master July 8, 2026 16:47
@Mbeaulne Mbeaulne force-pushed the 06-29-query_weight_change branch from f48e1e3 to 66f76ec Compare July 8, 2026 16:47
if (!field) return;

const currentWeight = fieldWeights[field];
let nextWeight = currentWeight;
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