Skip to content

Conversation

Sicheng-Pan
Copy link
Contributor

@Sicheng-Pan Sicheng-Pan commented Sep 8, 2025

Description of changes

Summarize the changes made by this PR.

  • Improvements & Bug fixes
    • N/A
  • New functionality
    • Allows the user to specify a None rank expression, in which case the the search behaves as if it is a get.

Test plan

How are these changes tested?

  • Tests pass locally with pytest for python, yarn test for js, cargo test for rust

Migration plan

Are there any migrations, or any forwards/backwards compatibility changes needed in order to make sure this change deploys reliably?

Observability plan

What is the plan to instrument and monitor this change?

Documentation Changes

Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the docs section?

Copy link

github-actions bot commented Sep 8, 2025

Reviewer Checklist

Please leverage this checklist to ensure your code review is thorough before approving

Testing, Bugs, Errors, Logs, Documentation

  • Can you think of any use case in which the code does not behave as intended? Have they been tested?
  • Can you think of any inputs or external events that could break the code? Is user input validated and safe? Have they been tested?
  • If appropriate, are there adequate property based tests?
  • If appropriate, are there adequate unit tests?
  • Should any logging, debugging, tracing information be added or removed?
  • Are error messages user-friendly?
  • Have all documentation changes needed been made?
  • Have all non-obvious changes been commented?

System Compatibility

  • Are there any potential impacts on other parts of the system or backward compatibility?
  • Does this change intersect with any items on our roadmap, and if so, is there a plan for fitting them together?

Quality

  • Is this code of a unexpectedly high quality (Readability, Modularity, Intuitiveness)

@Sicheng-Pan Sicheng-Pan marked this pull request as ready for review September 8, 2025 22:56
Copy link
Contributor

propel-code-bot bot commented Sep 8, 2025

Refactor and Generalize Search Ranking: Make RankExpr Optional/Operational in Search API

This PR performs a significant rework of the search API's ranking mechanism, transitioning from a required, enum-based Rank to an optional, expression-based RankExpr. The main focus is to allow search payloads to specify None for the rank expression, enabling search requests to behave identically to 'get' requests (ordered by offset_id, no custom ranking). This involves broad changes across the Rust backend/types, query execution orchestration, Protobuf definitions, Python client data model, and related integration points.

Key Changes

• Replaces the flat enum-based Rank with a new struct Rank { expr: Option<RankExpr> }, enabling optional ranking expressions.
• Moves all prior ranking arithmetic (abs, div, max, knn, val, etc.) under the new tree-based RankExpr enum and updates serialization logic.
• Allows rank: None in search payloads: search behaves as if no custom scoring is applied (default ordering).
• Refactors Protobuf (IDL) to replace Rank with RankExpr and introduce RankOperator` { optional `RankExpr` expr }`, propagating up to SearchPayload. • Updates all Rust operator code, orchestration pipelines, and server logic to correctly branch based on presence or absence of a rank expression. • Rewrites Python `Search` class semantics and documentation to make `.rank` optional and propagate `None` correctly in the API``.
• Adapts existing test cases and code generation logic to cover both ranked and non-ranked searches, ensuring backward compatibility and correct non-ranking behavior.
• Minor: Adjusts limit handling, rewrites docs and comments for clarity, updates field defaulting and serialization/deserialization in plan and operator structs.

Affected Areas

• Rust backend execution (operator.rs, plan.rs, orchestration/rank.rs, operators/rank.rs, server.rs)
IDL/Protobuf definitions (query_executor.proto)
• Python expression API (plan.py, data model)
• Frontend integration for search embedding counting (service_based_frontend.rs)
• Commit message conventions (organization of changes across commits)

This summary was automatically generated by @propel-code-bot

@Sicheng-Pan Sicheng-Pan force-pushed the 09-08-_enh_make_rank_expr_operational_in_search_api branch from dd5e08b to 23549e6 Compare September 9, 2025 16:00
@Sicheng-Pan Sicheng-Pan force-pushed the 09-04-_enh_transpose_search_api_response branch from 8828057 to 7f942e7 Compare September 9, 2025 16:00
@Sicheng-Pan Sicheng-Pan force-pushed the 09-08-_enh_make_rank_expr_operational_in_search_api branch from a481117 to bc8df61 Compare September 9, 2025 16:19
@Sicheng-Pan Sicheng-Pan force-pushed the 09-04-_enh_transpose_search_api_response branch from 7f942e7 to a02da4a Compare September 9, 2025 16:19
@Sicheng-Pan Sicheng-Pan changed the base branch from 09-04-_enh_transpose_search_api_response to graphite-base/5429 September 9, 2025 16:53
@Sicheng-Pan Sicheng-Pan force-pushed the 09-08-_enh_make_rank_expr_operational_in_search_api branch from bc8df61 to 1cb2444 Compare September 9, 2025 16:54
@graphite-app graphite-app bot changed the base branch from graphite-base/5429 to main September 9, 2025 16:55
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