Skip to content

Conversation

@bsbodden
Copy link
Collaborator

Implements native support for Redis field attributes UNF (un-normalized form) and NOINDEX to provide more control over field indexing and sorting behavior.

BREAKING CHANGE: None - all changes are backward compatible with default values

  • Add no_index attribute to BaseFieldAttributes for all field types
  • Add unf attribute to TextFieldAttributes and NumericFieldAttributes
  • Both attributes default to False maintaining backward compatibility

Field Support:

  • TextField: Supports both no_index and unf attributes
  • NumericField: Supports both no_index and unf attributes
  • TagField: Supports no_index attribute
  • GeoField: Supports no_index attribute

Technical Implementation:

  • NOINDEX implemented via redis-py's native no_index parameter
  • UNF added via args_suffix manipulation with proper ordering
  • Both attributes require sortable=True to take effect
  • Special parsing logic handles Redis auto-adding UNF to sortable numeric fields

Fixes #374

Implements native support for Redis field attributes UNF (un-normalized form) and NOINDEX
to provide more control over field indexing and sorting behavior.

BREAKING CHANGE: None - all changes are backward compatible with default values

- Add `no_index` attribute to BaseFieldAttributes for all field types
- Add `unf` attribute to TextFieldAttributes and NumericFieldAttributes
- Both attributes default to False maintaining backward compatibility

Field Support:
- TextField: Supports both no_index and unf attributes
- NumericField: Supports both no_index and unf attributes
- TagField: Supports no_index attribute
- GeoField: Supports no_index attribute

Technical Implementation:
- NOINDEX implemented via redis-py's native no_index parameter
- UNF added via args_suffix manipulation with proper ordering
- Both attributes require sortable=True to take effect
- Special parsing logic handles Redis auto-adding UNF to sortable numeric fields

Fixes #374
@bsbodden bsbodden requested a review from Copilot September 26, 2025 19:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements native support for Redis field attributes UNF (un-normalized form) and NOINDEX, providing better control over field indexing and sorting behavior in Redis search indices.

  • Adds no_index attribute to BaseFieldAttributes and unf attribute to TextFieldAttributes and NumericFieldAttributes with default values of False
  • Implements proper Redis command generation for both attributes with correct ordering (UNF before NOINDEX)
  • Updates schema parsing to handle these attributes when loading existing indices from Redis

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tests/unit/test_unf_noindex_fields.py Comprehensive unit tests covering all field types with new attributes
tests/integration/test_unf_noindex_integration.py Integration tests validating real Redis behavior with NOINDEX and UNF
redisvl/schema/fields.py Core implementation adding attributes and Redis field generation logic
redisvl/redis/connection.py Schema parsing logic to handle UNF/NOINDEX when loading existing indices

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Collaborator

@justin-cechmanek justin-cechmanek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@bsbodden bsbodden merged commit 2660e2f into main Sep 27, 2025
39 checks passed
@bsbodden bsbodden deleted the bsb/issue-374 branch September 27, 2025 01:18
bsbodden added a commit to redis/redis-vl-java that referenced this pull request Oct 23, 2025
Add support for UNF (un-normalized form) and NOINDEX attributes
for schema field classes, following Python RedisVL PR #386.

Features:
- TextField: Add UNF support via Jedis sortableUNF()
- NumericField: Add UNF flag (stored but limited by Jedis)
- NOINDEX: Already supported via indexed=false
- Comprehensive unit tests (16 tests)
- Maintains backward compatibility

Key behaviors:
- UNF only applies when sortable=true
- UNF preserves original character case for sorting
- NOINDEX prevents indexing, field still sortable/retrievable
- TextField & NumericField support both UNF and NOINDEX
- TagField & GeoField support NOINDEX only

Limitations:
- Jedis NumericField doesn't have sortableUNF() yet
- Filed TODO to request Jedis enhancement

Python Reference: redis/redis-vl-python#386

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
bsbodden added a commit to redis/redis-vl-java that referenced this pull request Oct 23, 2025
Add support for UNF (un-normalized form) and NOINDEX attributes
for schema field classes, following Python RedisVL PR #386.

Features:
- TextField: Add UNF support via Jedis sortableUNF()
- NumericField: Add UNF flag (stored but limited by Jedis)
- NOINDEX: Already supported via indexed=false
- Comprehensive unit tests (16 tests)
- Maintains backward compatibility

Key behaviors:
- UNF only applies when sortable=true
- UNF preserves original character case for sorting
- NOINDEX prevents indexing, field still sortable/retrievable
- TextField & NumericField support both UNF and NOINDEX
- TagField & GeoField support NOINDEX only

Limitations:
- Jedis NumericField doesn't have sortableUNF() yet
- Filed TODO to request Jedis enhancement

Python Reference: redis/redis-vl-python#386
bsbodden added a commit to redis/redis-vl-java that referenced this pull request Oct 23, 2025
Add support for UNF (un-normalized form) and NOINDEX attributes
for schema field classes, following Python RedisVL PR #386.

Features:
- TextField: Add UNF support via Jedis sortableUNF()
- NumericField: Add UNF flag (stored but limited by Jedis)
- NOINDEX: Already supported via indexed=false
- Comprehensive unit tests (16 tests)
- Maintains backward compatibility

Key behaviors:
- UNF only applies when sortable=true
- UNF preserves original character case for sorting
- NOINDEX prevents indexing, field still sortable/retrievable
- TextField & NumericField support both UNF and NOINDEX
- TagField & GeoField support NOINDEX only

Limitations:
- Jedis NumericField doesn't have sortableUNF() yet
- Filed TODO to request Jedis enhancement

Python Reference: redis/redis-vl-python#386
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.

Add native support for UNF and NOINDEX field attributes in RedisVL schema

3 participants