Skip to content

Add query-aware search policies#27

Merged
jolestar merged 2 commits into
mainfrom
fix/issue-26-dynamic-search-policy
Mar 30, 2026
Merged

Add query-aware search policies#27
jolestar merged 2 commits into
mainfrom
fix/issue-26-dynamic-search-policy

Conversation

@jolestar
Copy link
Copy Markdown
Owner

Summary

  • add optional search.policy.shortQuery and search.policy.longQuery on top of site-level search defaults
  • resolve search options in mdorigin based on trimmed query length while keeping /api/search limited to q, topK, and meta.*
  • document dynamic policy behavior, including null overrides that explicitly clear inherited defaults

Testing

  • npm run check
  • npm test

Closes #26

Copilot AI review requested due to automatic review settings March 30, 2026 10:32
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a query-aware “policy” layer to mdorigin’s search configuration so retrieval behavior can vary for short vs long queries, while keeping the public /api/search surface limited to q, topK, and meta.* filters.

Changes:

  • Introduce search.policy.shortQuery / search.policy.longQuery config (with null to explicitly clear inherited defaults) and normalize it in site config loading.
  • Resolve effective search options per request based on trimmed query length (Unicode code points), with shortQuery taking precedence when thresholds overlap.
  • Add tests and documentation covering dynamic policy behavior and precedence rules.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/search.ts Adds policy-aware option resolution and applies it across SearchApi implementations.
src/search.test.ts Adds integration tests validating long/short policy selection and null clearing behavior.
src/core/site-config.ts Extends and normalizes site search config to support query-aware policy entries.
src/core/site-config.test.ts Verifies policy normalization (including null overrides) during config loading.
skills/mdorigin/SKILL.md Notes that sites can configure query-aware search policies.
docs/site/reference/configuration.md Documents policy keys, matching rules, and null clearing semantics with an example.
docs/site/guides/getting-started.md Adds getting-started guidance and example config for dynamic search policy.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/search.ts Outdated
Comment on lines +25 to +28
SiteSearchLongQueryPolicyConfig,
SiteSearchPolicyOverrideConfig,
SiteSearchRerankerConfig,
SiteSearchShortQueryPolicyConfig,
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SiteSearchLongQueryPolicyConfig and SiteSearchShortQueryPolicyConfig are imported but never used in this file. Removing unused type imports will keep the module clean and avoids future lint/CI failures if unused-import checks are added.

Suggested change
SiteSearchLongQueryPolicyConfig,
SiteSearchPolicyOverrideConfig,
SiteSearchRerankerConfig,
SiteSearchShortQueryPolicyConfig,
SiteSearchPolicyOverrideConfig,
SiteSearchRerankerConfig,

Copilot uses AI. Check for mistakes.
@jolestar jolestar merged commit f200fe8 into main Mar 30, 2026
1 check passed
@jolestar jolestar deleted the fix/issue-26-dynamic-search-policy branch March 30, 2026 10:53
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.

Add query-aware dynamic search policy on top of site search defaults

2 participants