MB-65018 add custom_filter/custom_score query nodes with context-driven callback hooks#2289
MB-65018 add custom_filter/custom_score query nodes with context-driven callback hooks#2289abhinavdangeti merged 19 commits intomasterfrom
Conversation
…en callback hooks
|
@maneuvertomars Let's make sure you scrub the proposed code once again for any nil handling, especially around pointer dereferencing. |
abhinavdangeti
left a comment
There was a problem hiding this comment.
@maneuvertomars Let's do a quick walk through tomorrow.
abhinavdangeti
left a comment
There was a problem hiding this comment.
Please wait for review from @CascadingRadium as well.
|
@maneuvertomars please add functions to create new custom_filter/custom_score queries in |
|
@maneuvertomars lets also capture the behavior in the |
Looks like you already covered this with your last patch 👍🏼 |
There was a problem hiding this comment.
Pull request overview
Adds first-class custom_filter and custom_score query nodes that allow embedders to inject per-hit filtering and score mutation logic, while keeping Bleve core engine-agnostic and enabling optional doc-values-backed field access within callbacks.
Changes:
- Introduces
CustomFilterQuery/CustomScoreQueryJSON node support (via pluggable parsers) and corresponding searchers. - Implements doc value loading + field-type-aware decoding to populate
DocumentMatch.Fieldsbefore invoking callbacks. - Adds unit/integration tests and user-facing documentation for custom query behavior and requirements.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| search/searcher/search_custom_score.go | Adds a searcher wrapper that loads doc values and mutates hit scores via a callback. |
| search/searcher/search_custom_filter.go | Adds a searcher wrapper that loads doc values and applies a per-hit accept/drop callback. |
| search/searcher/search_custom_fields.go | Adds shared helpers to load doc values and decode them into typed DocumentMatch.Fields. |
| search/query/query.go | Extends ParseQuery to recognize custom_filter / custom_score nodes and delegate to embedder-registered parsers. |
| search/query/custom_score.go | Adds CustomScoreQuery type, JSON marshaling, validation, and searcher construction. |
| search/query/custom_filter.go | Adds CustomFilterQuery type, JSON marshaling, validation, and searcher construction. |
| search/query/custom_payload.go | Adds shared payload unmarshaling and mapping-type resolution utilities. |
| search/query/custom_query_test.go | Adds JSON marshal/unmarshal tests for both custom query types. |
| search_test.go | Adds end-to-end tests verifying filtering/scoring behavior and doc-values field decoding. |
| docs/custom_query.md | Adds documentation describing custom query nodes, payload semantics, and doc-values requirements. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Few more tiny changes @maneuvertomars, otherwise looks alright to me! |
|
Also @maneuvertomars please do click "resolve conversation" for the comments that you've taken care of, it's easier for everyone |
Addressed comments, approved by others.
This PR adds two new query node types in Bleve: custom_filter and custom_score, both wrapping an inner query.
Execution is embedding-driven via request-scoped context hooks (CustomFilterFactory / CustomScoreFactory) so Bleve remains engine-agnostic.
custom_filter applies per-hit keep/drop logic through FilteringSearcher; custom_score applies per-hit score mutation through ScoreMutatingSearcher.