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}
)

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
# 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
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.

1 participant