Skip to content

Conversation

bsbodden
Copy link
Collaborator

Adds the ability to specify weights for text fields in RedisVL queries, enabling users to prioritize certain fields over others in search results.

  • Support dictionary of field:weight mappings in TextQuery constructor
  • Maintain backward compatibility with single string field names
  • Add set_field_weights() method for dynamic weight updates
  • Generate proper Redis query syntax with weight modifiers
  • Comprehensive validation for positive numeric weights

Example usage:

# Single field with weight
query = TextQuery(text="search", text_field_name={"title": 5.0})

# Multiple fields with weights
query = TextQuery(
    text="search",
    text_field_name={"title": 3.0, "content": 1.5, "tags": 1.0}
)

@bsbodden bsbodden requested a review from rbs333 September 24, 2025 04:00
@bsbodden bsbodden removed the request for review from rbs333 September 25, 2025 21:58
Adds the ability to specify weights for text fields in RedisVL queries,
enabling users to prioritize certain fields over others in search results.

- Support dictionary of field:weight mappings in TextQuery constructor
- Maintain backward compatibility with single string field names
- Add set_field_weights() method for dynamic weight updates
- Generate proper Redis query syntax with weight modifiers
- Comprehensive validation for positive numeric weights

Example usage:
```python
query = TextQuery(text="search", text_field_name={"title": 5.0})

query = TextQuery(
    text="search",
    text_field_name={"title": 3.0, "content": 1.5, "tags": 1.0}
)
```

- Add has_redisearch_module and has_redisearch_module_async helpers to conftest.py
- Add skip_if_no_redisearch and skip_if_no_redisearch_async functions
- Update test_no_proactive_module_checks.py to use shared helpers
- Update test_semantic_router.py to check RediSearch availability in fixtures and tests
- Update test_llmcache.py to check RediSearch availability in all cache fixtures
- Update test_message_history.py to check RediSearch availability for semantic history
- Ensure all tests that require RediSearch are properly skipped on Redis 6.2.6-v9
- BM25STD scorer is not available in Redis versions prior to 7.2.0. Add version check to skip these tests on older Redis versions.
@abrookins
Copy link
Collaborator

Nice one.

@bsbodden bsbodden self-assigned this Sep 26, 2025
@bsbodden bsbodden merged commit 7607554 into main Sep 26, 2025
37 checks passed
@bsbodden bsbodden deleted the bsb/issue-360 branch September 26, 2025 16:39
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.

2 participants