Skip to content

feat(qdrant): Add filtering system for Qdrant vector searches#22

Merged
Shinu95J merged 5 commits into
mainfrom
feat/extend_filters
Dec 10, 2025
Merged

feat(qdrant): Add filtering system for Qdrant vector searches#22
Shinu95J merged 5 commits into
mainfrom
feat/extend_filters

Conversation

@Shinu95J
Copy link
Copy Markdown
Contributor

@Shinu95J Shinu95J commented Dec 7, 2025

Add type-safe filtering system

Summary

Adds a comprehensive, type-safe filtering system for Qdrant vector searches with support for multiple condition types and logical clauses.

Filter Conditions

Type Description SQL Equivalent
TextCondition Exact string match WHERE city = 'London'
BoolCondition Boolean match WHERE active = true
IntCondition Integer match WHERE priority = 1
TextAnyCondition Match any of values WHERE city IN ('London', 'Berlin')
IntAnyCondition Match any of integers WHERE priority IN (1, 2, 3)
TextExceptCondition Exclude values WHERE city NOT IN ('Paris')
IntExceptCondition Exclude integers WHERE priority NOT IN (0)
TimeRangeCondition Datetime range WHERE created_at >= '2024-01-01'
NumericRangeCondition Numeric range (float) WHERE price >= 100 AND price <= 500
IsNullCondition Check if field is null WHERE deleted_at IS NULL
IsEmptyCondition Check if field is empty/missing WHERE tags IS EMPTY

Logical Clauses

Clause Logic JSON Key Description
Must AND must All conditions must match
Should OR should At least one condition must match
MustNot NOT mustNot None of the conditions should match

Field Type Separation

Field Type Storage Location Example
InternalField Payload top-level search_store_id
UserField Under custom. prefix custom.document_id

JSON Serialization

Condition Field JSON Key
Key field
Value (match) equalTo
Values (any) anyOf
Values (except) noneOf
TimeRange.Gt after
TimeRange.Gte atOrAfter
TimeRange.Lt before
TimeRange.Lte atOrBefore
NumericRange.Gt greaterThan
NumericRange.Gte greaterThanOrEqualTo
NumericRange.Lt lessThan
NumericRange.Lte lessThanOrEqualTo

Usage

filters := &FilterSet{
    Must: &ConditionSet{
        Conditions: []FilterCondition{
            TextCondition{Key: "search_store_id", Value: "store-123"},
            TextAnyCondition{Key: "city", Values: []string{"London", "Berlin"}},
            TimeRangeCondition{
                Key:   "created_at",
                Value: TimeRange{Gte: &startTime, Lt: &endTime},
            },
            NumericRangeCondition{
                Key:       "price",
                Value:     NumericRange{Gte: &minPrice, Lte: &maxPrice},
                FieldType: UserField,
            },
        },
    },
    MustNot: &ConditionSet{
        Conditions: []FilterCondition{
            BoolCondition{Key: "deleted", Value: true},
            IsEmptyCondition{Key: "tags"},
        },
    },
}

JSON Output Example

{
  "must": [
    {"field": "search_store_id", "equalTo": "store-123"},
    {"field": "city", "anyOf": ["London", "Berlin"]},
    {"field": "created_at", "atOrAfter": "2024-01-01T00:00:00Z", "before": "2024-12-31T00:00:00Z"},
    {"field": "price", "greaterThanOrEqualTo": 100, "lessThanOrEqualTo": 500}
  ],
  "mustNot": [
    {"field": "deleted", "equalTo": true},
    {"field": "tags"}
  ]
}

Payload Helper


payload := BuildPayload(
    map[string]any{"search_store_id": "store-123"},  // Internal (top-level)
    map[string]any{"document_id": "doc-456"},        // User → custom.document_id
)

@Shinu95J Shinu95J changed the title feat(qdrant): Add type-safe filtering system feat(qdrant): Add filtering system for Qdrant vector searches Dec 7, 2025
Comment thread v1/qdrant/filters.go Outdated
Comment thread v1/qdrant/filters.go Outdated
@Shinu95J Shinu95J force-pushed the feat/extend_filters branch from 9a5e89b to df523df Compare December 10, 2025 13:39
@Shinu95J Shinu95J merged commit 1ef9423 into main Dec 10, 2025
3 checks passed
@Shinu95J Shinu95J deleted the feat/extend_filters branch December 10, 2025 13:52
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.

4 participants