mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 17:48:29 +08:00
### Is there an existing issue for this? - [x] I have searched the existing issues --- Please see: https://github.com/milvus-io/milvus/issues/44593 for the background This PR makes https://github.com/milvus-io/milvus/pull/44638 redundant, which can be closed. The PR comments for the original implementation suggested an alternative and a better approach, this new PR has that implementation. --- This PR - Adds an optional `minimum_should_match` argument to `text_match(...)` and wires it through the parser, planner/visitor, index bindings, and client-level tests/examples so full-text queries can require a minimum number of tokens to match. Motivation - Provide a way to require an expression to match a minimum number of tokens in lexical search. What changed - Parser / grammar - Added grammar rule and token: `MINIMUM_SHOULD_MATCH` and `textMatchOption` in `internal/parser/planparserv2/Plan.g4`. - Regenerated parser outputs: `internal/parser/planparserv2/generated/*` (parser, lexer, visitor, etc.) to support the new rule. - Planner / visitor - `parser_visitor.go`: parse and validate the `minimum_should_match` integer; propagate as an extra value on the `TextMatch` expression so downstream components receive it. - Added `VisitTextMatchOption` visitor method handling. - Client (Golang) - Added a unit test to verify `text_match(..., minimum_should_match=...)` appears in the generated DSL and is accepted by client code: `client/milvusclient/read_test.go` (new test coverage). - Added an integration-style test for the feature to the go-client testcase suite: `tests/go_client/testcases/full_text_search_test.go` (exercise min=1, min=3, large min). - Added an example demonstrating `text_match` usage: `client/milvusclient/read_example_test.go` (example name conforms to godoc mapping). - Engine / index - Updated C++ index interface: `TextMatchIndex::MatchQuery` - Added/updated unit tests for the index behavior: `internal/core/src/index/TextMatchIndexTest.cpp`. - Tantivy binding - Added `match_query_with_minimum` implementation and unit tests to `internal/core/thirdparty/tantivy/tantivy-binding/src/index_reader_text.rs` that construct boolean queries with minimum required clauses. Behavioral / compatibility notes - This adds an optional argument to `text_match` only; default behavior (no `minimum_should_match`) is unchanged. - Internal API change: `TextMatchIndex::MatchQuery` signature changed (internal component). Callers in the repo were updated accordingly. - Parser changes required regenerating ANTLR outputs Tests and verification - New/updated tests: - Go client unit test: `client/milvusclient/read_test.go` (mocked Search request asserts DSL contains `minimum_should_match=2`). - Go e2e-style test: `tests/go_client/testcases/full_text_search_test.go` (exercises min=1, 3 and a large min). - C++ unit tests for index behavior: `internal/core/src/index/TextMatchIndexTest.cpp`. - Rust binding unit tests for `match_query_with_minimum`. - Local verification commands to run: - Go client tests: `cd client && go test ./milvusclient -run ^$` (client package) - Go testcases: `cd tests/go_client && go test ./testcases -run TestTextMatchMinimumShouldMatch` (requires a running Milvus instance) - C++ unit tests / build: run core build/test per repo instructions (the change touches core index code). - Rust binding tests: `cd internal/core/thirdparty/tantivy/tantivy-binding && cargo test` (if developing locally). --------- Signed-off-by: Amit Kumar <amit.kumar@reddit.com> Co-authored-by: Amit Kumar <amit.kumar@reddit.com>
201 lines
5.4 KiB
Go
201 lines
5.4 KiB
Go
// Code generated from Plan.g4 by ANTLR 4.13.2. DO NOT EDIT.
|
|
|
|
package planparserv2 // Plan
|
|
import "github.com/antlr4-go/antlr/v4"
|
|
|
|
type BasePlanVisitor struct {
|
|
*antlr.BaseParseTreeVisitor
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitJSONIdentifier(ctx *JSONIdentifierContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitRandomSample(ctx *RandomSampleContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitParens(ctx *ParensContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitString(ctx *StringContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitFloating(ctx *FloatingContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitJSONContainsAll(ctx *JSONContainsAllContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitLogicalOr(ctx *LogicalOrContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitIsNotNull(ctx *IsNotNullContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitMulDivMod(ctx *MulDivModContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitIdentifier(ctx *IdentifierContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitSTIntersects(ctx *STIntersectsContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitLike(ctx *LikeContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitLogicalAnd(ctx *LogicalAndContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitTemplateVariable(ctx *TemplateVariableContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitEquality(ctx *EqualityContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitBoolean(ctx *BooleanContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitTimestamptzCompareReverse(ctx *TimestamptzCompareReverseContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitSTDWithin(ctx *STDWithinContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitShift(ctx *ShiftContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitTimestamptzCompareForward(ctx *TimestamptzCompareForwardContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitCall(ctx *CallContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitSTCrosses(ctx *STCrossesContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitReverseRange(ctx *ReverseRangeContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitBitOr(ctx *BitOrContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitEmptyArray(ctx *EmptyArrayContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitAddSub(ctx *AddSubContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitPhraseMatch(ctx *PhraseMatchContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitRelational(ctx *RelationalContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitArrayLength(ctx *ArrayLengthContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitTextMatch(ctx *TextMatchContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitSTTouches(ctx *STTouchesContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitSTContains(ctx *STContainsContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitTerm(ctx *TermContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitJSONContains(ctx *JSONContainsContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitSTWithin(ctx *STWithinContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitRange(ctx *RangeContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitUnary(ctx *UnaryContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitInteger(ctx *IntegerContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitArray(ctx *ArrayContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitJSONContainsAny(ctx *JSONContainsAnyContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitBitXor(ctx *BitXorContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitExists(ctx *ExistsContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitBitAnd(ctx *BitAndContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitSTEuqals(ctx *STEuqalsContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitIsNull(ctx *IsNullContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitPower(ctx *PowerContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitSTOverlaps(ctx *STOverlapsContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|
|
|
|
func (v *BasePlanVisitor) VisitTextMatchOption(ctx *TextMatchOptionContext) interface{} {
|
|
return v.VisitChildren(ctx)
|
|
}
|