Skip to content

Conversation

@nkanu17
Copy link
Collaborator

@nkanu17 nkanu17 commented Nov 20, 2025

Fix field modifier ordering to satisfy RediSearch parser requirements where
INDEXEMPTY and INDEXMISSING must appear BEFORE SORTABLE in field definitions.
This resolves index creation failures when using index_missing=True with
sortable=True.

Changes:

  • Add _normalize_field_modifiers() helper function with set-based optimization
  • Refactor TextField, TagField, NumericField, GeoField to use helper
  • Implement canonical order: [INDEXEMPTY] [INDEXMISSING] [SORTABLE [UNF]] [NOINDEX]
  • Add unit tests for helper and field classes
  • Add integration tests against live Redis

Fixes: issue #431
Related: Field 'INDEXMISSING' does not have a type error

BREAKING CHANGE: None - backward compatible, only changes internal ordering

…earch parser

Fix field modifier ordering to satisfy RediSearch parser requirements where
INDEXEMPTY and INDEXMISSING must appear BEFORE SORTABLE in field definitions.
This resolves index creation failures when using index_missing=True with
sortable=True.
@nkanu17 nkanu17 requested review from abrookins, bsbodden, Copilot, justin-cechmanek and rbs333 and removed request for Copilot November 20, 2025 21:14
Copilot finished reviewing on behalf of nkanu17 November 20, 2025 21:19
Copilot AI review requested due to automatic review settings November 20, 2025 21:31
Copilot finished reviewing on behalf of nkanu17 November 20, 2025 21:36
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 fixes a critical RediSearch parser limitation where INDEXEMPTY and INDEXMISSING modifiers must appear before SORTABLE in field definitions. The fix introduces a helper function _normalize_field_modifiers() that reorders field modifiers to match the required canonical order, preventing index creation failures when using index_missing=True with sortable=True.

Key Changes:

  • Added _normalize_field_modifiers() helper function with set-based optimization for reordering field modifiers
  • Refactored TextField, TagField, NumericField, and GeoField to use the helper function
  • Added comprehensive unit and integration tests covering various modifier combinations

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.

File Description
redisvl/schema/fields.py Core implementation: Added _normalize_field_modifiers() helper and updated field classes to normalize modifier ordering; includes minor PEP 8 spacing improvement
tests/unit/test_field_modifier_ordering.py Comprehensive unit tests for the helper function and all field types with various modifier combinations
tests/integration/test_field_modifier_ordering_integration.py Integration tests against live Redis to verify index creation succeeds with reordered modifiers

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings November 20, 2025 22:44
Copilot finished reviewing on behalf of nkanu17 November 20, 2025 22:46
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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings November 21, 2025 00:51
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

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

try:
index.delete(drop=True)
except Exception:
pass # Index may not exist if test was skipped or failed early
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

[nitpick] The comment should clarify that this handles cleanup errors, not just test skips. Consider: pass # Cleanup may fail if test was skipped, failed early, or index was already deleted

Copilot uses AI. Check for mistakes.
BaseVectorQuery,
CountQuery,
FilterQuery,
TextQuery,
Copy link

Copilot AI Nov 21, 2025

Choose a reason for hiding this comment

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

[nitpick] The TextQuery import is added but should be grouped with other query imports for better organization. Consider placing it alphabetically with BaseVectorQuery, CountQuery, and FilterQuery on the same line or ensuring consistent multi-line formatting.

Copilot uses AI. Check for mistakes.
@nkanu17 nkanu17 force-pushed the RAAE-1199-redisvl-ft-create-fails-when-using-indexmissing-sortable-and-unf-togethertable-true-and-unf-true-fails-at-index-creation branch from bce7e6f to 94e2ff2 Compare November 21, 2025 00:54
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