fix(hgraph): expose skip_ratio and skip_strategy search parameters#2367
Conversation
Merge Protections🟢 All 3 merge protections satisfied — ready to merge. Show 3 satisfied protections🟢 Require kind label
🟢 Require version label
🟢 Require linked issue for feature/bug PRs
|
There was a problem hiding this comment.
Code Review
This pull request introduces two new filter-related search parameters for hgraph: skip_ratio and skip_strategy. It includes updates to the English and Chinese documentation, JSON parsing logic, parameter mapping during search, and corresponding unit tests. The review feedback highlights that the documentation for skip_ratio is currently backwards and needs correction. Additionally, it is recommended to add range validation for skip_ratio to ensure it remains within [0.0, 1.0], along with unit tests to verify that out-of-range values are properly rejected.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
There was a problem hiding this comment.
Pull request overview
Expose HGraph’s previously internal filter-skip controls as user-configurable search parameters, enabling tuning of filtered-search speed/recall trade-offs via JSON search params.
Changes:
- Add
skip_ratioandskip_strategy_typetoHGraphSearchParameterswith defaults aligned to existing behavior. - Parse
skip_ratio/skip_strategyfrom JSON and propagate them intoInnerSearchParamfor bothKnnSearchandSearchWithRequest. - Add unit tests and update EN/ZH index-parameter documentation.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/algorithm/hgraph/hgraph_search.cpp | Plumbs new skip parameters into InnerSearchParam for HGraph search paths. |
| src/algorithm/hgraph/hgraph_parameter.h | Adds search-parameter fields and includes skip-strategy type definition. |
| src/algorithm/hgraph/hgraph_parameter.cpp | Parses new JSON parameters into HGraphSearchParameters. |
| src/algorithm/hgraph/hgraph_parameter_test.cpp | Adds unit tests for new parameter parsing defaults and overrides. |
| docs/docs/zh/src/resources/index_parameters.md | Documents new HGraph filter-related search parameters (ZH). |
| docs/docs/en/src/resources/index_parameters.md | Documents new HGraph filter-related search parameters (EN). |
1aa08c2 to
1e00909
Compare
1e00909 to
fab41d0
Compare
b5ad01b to
5655bef
Compare
549d2dc to
ef3b07f
Compare
ef3b07f to
ce1d6e5
Compare
ce1d6e5 to
2c38390
Compare
2c38390 to
e3f881d
Compare
e3f881d to
b272a8b
Compare
|
/label S-waiting-on-review |
|
Tick the box to add this pull request to the merge queue (same as
|
b272a8b to
ba8caa6
Compare
ba8caa6 to
8759f2e
Compare
8759f2e to
2456f49
Compare
Expose skip_ratio and skip_strategy as configurable search parameters for HGraph index. These parameters control the filter skip strategy during graph traversal, allowing users to tune the trade-off between search speed and recall when using filters. Key changes: - Add skip_ratio and skip_strategy_type fields to HGraphSearchParameters - Parse these parameters from JSON in FromJson() - Add validation for skip_ratio range [0.0, 1.0] - Pass parameters to InnerSearchParam in both KnnSearch and SearchWithRequest paths - Invert skip_ratio semantics to match parameter name meaning: skip_ratio now means "what percentage of invalid points to skip" - Remove special case for valid_ratio==1.0 in get_retain_ratio - Add unit tests for parameter parsing and validation - Update documentation (zh/en) with correct default value (0.2) skip_ratio semantics (after inversion): - skip_ratio=0.2 (default): skip 20% of invalid points - retain_ratio = (1 - valid_ratio) * (1 - skip_ratio) - visit_ratio = valid_ratio + retain_ratio The underlying skip mechanism was already supported in BasicSearcher/ ParallelSearcher since v0.17.0, but was never exposed through the public API for HGraph. This change maintains backward compatibility by using the same default value (0.2) that was previously hardcoded. Fixes: antgroup#2368 Signed-off-by: LHT129 <tianlan.lht@antgroup.com> Assisted-by: opencode:qwen3.7-plus
2456f49 to
92ad37f
Compare
Fixes #2368
Summary
Expose skip_ratio and skip_strategy as configurable search parameters for HGraph index. Previously these were hardcoded defaults (skip_ratio=0.8F) with no way for users to override via the public JSON search parameter API.
Changes
Default values
Breaking Change: skip_ratio semantics inverted
The skip_ratio parameter semantics have been inverted to match the parameter name.
Before: skip_ratio=0.8 meant visit 80% of invalid points.
After: skip_ratio=0.2 means skip 20% of invalid points (visit 80%).
Default values changed: HGraph 0.8 to 0.2, HNSW 0.9 to 0.1.
If using custom skip_ratio values, change to (1 - old_value) to maintain same behavior.