Skip to content

Improve endpoint search rankings#87

Merged
joedursun merged 2 commits into
masterfrom
joe.index
Apr 17, 2026
Merged

Improve endpoint search rankings#87
joedursun merged 2 commits into
masterfrom
joe.index

Conversation

@joedursun

Copy link
Copy Markdown
Collaborator

Improve search_endpoints quality. The original goal was to add a structured market filter; along the way we also tightened the ranking mechanism, indexed more of the already-parsed doc data, and expanded the query-token alias table then
measured against a 358-query evaluation harness that covers both mainstream traffic and long-tail partner/economy/indices endpoints.

Net result vs master: +9 hit@1, +3 hit@3, +8 hit@7, -8 complete misses. No impactful regressions (15 minor rank shifts within the top 3, all between sibling endpoints).

Changes

  • Structured market parameter on search_endpoints (Stocks | Options | Crypto | Forex | Futures | Indices | Economy | Alternative | Reference). Explicit values are a hard WHERE market = ? filter. Omitted → inferred from the query as before.
  • market stays as an indexed FTS column (not UNINDEXED) so its value ("Stocks", "Crypto", …) contributes to BM25. Combined with the multiplicative CASE WHEN market = ? THEN 2.0 ELSE 1.0 boost when a market is detected, inferred-market
    preference is robust across corpus sizes and doesn't hide strong cross-market matches (e.g. "stock ratings" still returns Analyst Ratings under Partners).
  • New attrs FTS column (weight 0.1) that indexes response-attribute field names like debt_to_equity, yield_10_year, ask_price. Zero extra network, ~200 KB extra FTS text, and it fixes a long list of jargon queries without hand-curated
    aliases. Query-param names are intentionally excluded (dominated by generic filter operators like ticker/date/limit).
  • Expanded ALIASES and _MARKET_KEYWORDS: labor/employment (nonfarm, jobless, claims), inflation (breakeven), filings (edgar), ratios (roe, roa, roic), merchant (mcc), commodity root keywords (crude, oil, gold, cme, …), index symbols (spx,
    djia, dow). Dropped index from Indices keywords — it was misrouting queries like "consumer price index" and "SEC EDGAR index". Also cross-expanded aggregate(s) ↔ bars / ohlc so "aggregates" queries find Custom Bars titles.
  • Title-based dedup kept — plus over-fetch factor stays at 4× top_k to compensate for cross-market title collisions (e.g. 5× "Unified Snapshot").

Test plan

  • uv run pytest tests/ — 661 pass (up from 645 on master; 16 new tests)
  • New TestInferredMarketBoost covers the CASE-boost mechanism, including the regression-guard test_cross_market_title_match_beats_inferred_boost that pins down the "stock ratings" → Analyst Ratings case
  • New TestAttrsColumn covers response-attribute indexing, the results[]. prefix strip, and that query-param names are not in the attrs column
  • Manual spot-check: search_endpoints("aggregate bars", market="Crypto"), search_endpoints("ROE"), search_endpoints("debt to equity"), search_endpoints("stock ratings"), search_endpoints("ETF categories") all return the expected endpoint at rank 1 or 2.

Simplify endpoint index and tighten filter semantics
Comment thread src/mcp_massive/index.py
@joedursun
joedursun merged commit 62ba117 into master Apr 17, 2026
5 checks passed
@joedursun
joedursun deleted the joe.index branch April 17, 2026 18:07
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.

2 participants