Skip to content

fix(hgraph): expose skip_ratio and skip_strategy search parameters#2367

Merged
LHT129 merged 1 commit into
antgroup:mainfrom
LHT129:lht/hgraph-skip-ratio
Jul 7, 2026
Merged

fix(hgraph): expose skip_ratio and skip_strategy search parameters#2367
LHT129 merged 1 commit into
antgroup:mainfrom
LHT129:lht/hgraph-skip-ratio

Conversation

@LHT129

@LHT129 LHT129 commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

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

  • Add skip_ratio and skip_strategy_type fields to HGraphSearchParameters
  • Parse skip_ratio and skip_strategy from JSON in HGraphSearchParameters::FromJson()
  • Pass values to InnerSearchParam in both KnnSearch (iterator) and SearchWithRequest paths
  • Add unit tests for parameter parsing
  • Update index_parameters.md documentation (zh/en)

Default values

  • skip_ratio: 0.8F (matches InnerSearchParam default, backward compatible)
  • skip_strategy_type: DETERMINISTIC_ACCUMULATIVE

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.

Copilot AI review requested due to automatic review settings June 29, 2026 11:34
@LHT129 LHT129 added kind/feature Brand-new functionality or capabilities 引入全新的功能、新特性或新能力 version/1.0 labels Jun 29, 2026
@mergify mergify Bot added the module/docs label Jun 29, 2026
@mergify

mergify Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 All 3 merge protections satisfied — ready to merge.

Show 3 satisfied protections

🟢 Require kind label

  • label~=^kind/

🟢 Require version label

  • label~=^version/

🟢 Require linked issue for feature/bug PRs

  • body~=(?im)(?:^|[\s\-\*])(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s*:?\s+(?:#\d+|[\w.\-]+/[\w.\-]+#\d+|https?://github\.com/[\w.\-]+/[\w.\-]+/issues/\d+)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment thread docs/docs/en/src/resources/index_parameters.md Outdated
Comment thread docs/docs/zh/src/resources/index_parameters.md Outdated
Comment thread src/algorithm/hgraph/hgraph_parameter.cpp
Comment thread src/algorithm/hgraph/hgraph_parameter_test.cpp

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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_ratio and skip_strategy_type to HGraphSearchParameters with defaults aligned to existing behavior.
  • Parse skip_ratio / skip_strategy from JSON and propagate them into InnerSearchParam for both KnnSearch and SearchWithRequest.
  • 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).

Comment thread src/algorithm/hgraph/hgraph_parameter.cpp
Comment thread docs/docs/en/src/resources/index_parameters.md Outdated
Comment thread docs/docs/zh/src/resources/index_parameters.md Outdated
Comment thread src/algorithm/hgraph/hgraph_parameter_test.cpp Outdated
@LHT129 LHT129 added kind/bug Bug fixes, defects, or unexpected behavior 修复程序错误、缺陷或异常行为 and removed kind/feature Brand-new functionality or capabilities 引入全新的功能、新特性或新能力 labels Jun 29, 2026
@LHT129 LHT129 self-assigned this Jun 29, 2026
@LHT129 LHT129 force-pushed the lht/hgraph-skip-ratio branch from 1aa08c2 to 1e00909 Compare June 29, 2026 12:48
@LHT129 LHT129 changed the title feat(hgraph): expose skip_ratio and skip_strategy search parameters fix(hgraph): expose skip_ratio and skip_strategy search parameters Jun 29, 2026
@LHT129 LHT129 force-pushed the lht/hgraph-skip-ratio branch from 1e00909 to fab41d0 Compare June 29, 2026 12:50
Copilot AI review requested due to automatic review settings June 30, 2026 02:39
@mergify mergify Bot added the module/index label Jun 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.

Comment thread src/algorithm/hgraph/hgraph_parameter.cpp
Comment thread src/index/hnsw_zparameters.h
Comment thread docs/docs/en/src/resources/index_parameters.md Outdated
Comment thread docs/docs/zh/src/resources/index_parameters.md Outdated
Comment thread src/impl/inner_search_param.h
Comment thread src/utils/filter_search_skip_strategy.cpp Outdated
Comment thread src/utils/filter_search_skip_strategy_test.cpp
Copilot AI review requested due to automatic review settings June 30, 2026 03:44
@pull-request-size pull-request-size Bot added size/L and removed size/M labels Jun 30, 2026
@LHT129 LHT129 force-pushed the lht/hgraph-skip-ratio branch from b5ad01b to 5655bef Compare June 30, 2026 03:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 12 comments.

Comment thread src/algorithm/hgraph/hgraph_parameter.cpp
Comment thread docs/docs/en/src/resources/index_parameters.md Outdated
Comment thread docs/docs/zh/src/resources/index_parameters.md Outdated
Comment thread docs/docs/en/src/indexes/hgraph.md Outdated
Comment thread docs/docs/zh/src/indexes/hgraph.md Outdated
Comment thread docs/docs/en/src/indexes/hgraph.md Outdated
Comment thread docs/docs/zh/src/indexes/hgraph.md Outdated
Comment thread docs/docs/zh/src/indexes/hgraph.md Outdated
Comment thread src/utils/filter_search_skip_strategy_test.cpp
Comment thread src/algorithm/hgraph/hgraph_parameter_test.cpp
Copilot AI review requested due to automatic review settings July 1, 2026 02:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@LHT129 LHT129 force-pushed the lht/hgraph-skip-ratio branch from 549d2dc to ef3b07f Compare July 2, 2026 02:49
Copilot AI review requested due to automatic review settings July 2, 2026 02:52
@LHT129 LHT129 force-pushed the lht/hgraph-skip-ratio branch from ef3b07f to ce1d6e5 Compare July 2, 2026 02:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 7 comments.

Comment thread src/algorithm/hgraph/hgraph_parameter.cpp
Comment thread docs/docs/en/src/indexes/hgraph.md Outdated
Comment thread docs/docs/en/src/indexes/hgraph.md Outdated
Comment thread docs/docs/en/src/indexes/hgraph.md
Comment thread docs/docs/zh/src/indexes/hgraph.md Outdated
Comment thread docs/docs/zh/src/indexes/hgraph.md Outdated
Comment thread docs/docs/zh/src/indexes/hgraph.md
@LHT129 LHT129 force-pushed the lht/hgraph-skip-ratio branch from ce1d6e5 to 2c38390 Compare July 2, 2026 03:06
Copilot AI review requested due to automatic review settings July 2, 2026 03:15
@LHT129 LHT129 force-pushed the lht/hgraph-skip-ratio branch from 2c38390 to e3f881d Compare July 2, 2026 03:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.

Comment thread docs/docs/en/src/indexes/hgraph.md
Comment thread docs/docs/en/src/indexes/hgraph.md Outdated
Comment thread docs/docs/zh/src/indexes/hgraph.md Outdated
Comment thread src/algorithm/hgraph/hgraph_parameter.cpp
Comment thread src/algorithm/hgraph/hgraph_parameter_test.cpp
Comment thread src/algorithm/hgraph/hgraph_parameter_test.cpp

@wxyucs wxyucs left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@LHT129 LHT129 force-pushed the lht/hgraph-skip-ratio branch from e3f881d to b272a8b Compare July 6, 2026 07:20
@vsag-bot

vsag-bot commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

/label S-waiting-on-review
/waiting-on reviewer
/request-review @jiaweizone
/request-review @inabao

@mergify

mergify Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Copilot AI review requested due to automatic review settings July 7, 2026 02:28
@LHT129 LHT129 force-pushed the lht/hgraph-skip-ratio branch from b272a8b to ba8caa6 Compare July 7, 2026 02:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Comment thread src/utils/filter_search_skip_strategy.cpp
Comment thread src/index/hnsw_zparameters.h Outdated
Comment thread src/algorithm/hgraph/hgraph_parameter_test.cpp Outdated
@LHT129 LHT129 force-pushed the lht/hgraph-skip-ratio branch from ba8caa6 to 8759f2e Compare July 7, 2026 03:15
Copilot AI review requested due to automatic review settings July 7, 2026 03:16
@LHT129 LHT129 force-pushed the lht/hgraph-skip-ratio branch from 8759f2e to 2456f49 Compare July 7, 2026 03:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Comment thread docs/docs/en/src/indexes/hgraph.md Outdated
Comment thread docs/docs/zh/src/indexes/hgraph.md Outdated
Comment thread src/impl/inner_search_param.h
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
@LHT129 LHT129 force-pushed the lht/hgraph-skip-ratio branch from 2456f49 to 92ad37f Compare July 7, 2026 03:53
@LHT129 LHT129 merged commit 25493b1 into antgroup:main Jul 7, 2026
20 checks passed
@LHT129 LHT129 deleted the lht/hgraph-skip-ratio branch July 7, 2026 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Bug fixes, defects, or unexpected behavior 修复程序错误、缺陷或异常行为 module/api module/docs module/index size/L version/1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: HGraph does not expose skip_ratio / skip_strategy search parameters

4 participants