Skip to content

Implement FT.INFO command#3599

Open
jruaux wants to merge 5 commits intomainfrom
ft-info-command
Open

Implement FT.INFO command#3599
jruaux wants to merge 5 commits intomainfrom
ft-info-command

Conversation

@jruaux
Copy link
Copy Markdown
Contributor

@jruaux jruaux commented Dec 28, 2025

This PR implements the FT.INFO command to retrieve index information from RediSearch.

The implementation returns a IndexInfo object.

Changes:

  • Add IndexInfo class with index information including:
    • Basic index information (name, document counts, terms, records)
    • Index options and definition
    • Schema attributes
    • Size statistics (memory usage)
    • Indexing statistics (progress, failures, timing)
    • Garbage collection statistics
    • Cursor statistics
    • Dialect usage statistics
    • Error statistics
  • Add IndexInfoParser supporting both RESP2 and RESP3 protocols
  • Implement ftInfo across all API layers (sync, async, reactive, coroutines)
  • Add unit tests for IndexInfo class (11 tests, all passing)
  • Update integration tests

Testing:
All unit tests pass. Integration tests require a Redis instance with RediSearch module.


Note

Medium Risk
Adds a new RediSearch command with a large, protocol-sensitive RESP2/RESP3 parser and new data model; main risk is incorrect parsing/mapping of server responses across Redis/RediSearch versions.

Overview
Adds support for RediSearch FT.INFO across sync/async/reactive/coroutines (including cluster node-selection) APIs, returning a new strongly-typed IndexInfo result.

Introduces IndexInfo plus IndexInfoParser and wires them into RediSearchCommandBuilder via CommandType.FT_INFO, with extensive unit coverage to validate parsing for RESP2/RESP3, field schemas, and statistics/error sections.

Written by Cursor Bugbot for commit 2e197bf. This will update automatically on new commits. Configure here.

@jruaux jruaux changed the title Add FT.INFO command with strongly-typed IndexInfo response Implement FT.INFO command Dec 28, 2025
@jruaux jruaux marked this pull request as draft December 29, 2025 07:48
@jruaux jruaux marked this pull request as ready for review December 29, 2025 21:25
jruaux and others added 5 commits February 27, 2026 13:01
Implements FT.INFO command to retrieve index information from RediSearch.
Returns a strongly-typed IndexInfo object instead of Map<String, Object>
for better type safety and developer experience.

Changes:
- Add IndexInfo class with comprehensive index metadata
- Add IndexInfoParser supporting RESP2 and RESP3 protocols
- Implement ftInfo across all API layers (sync, async, reactive, coroutines)
- Add unit tests for IndexInfo class
- Update integration tests
- Changed IndexInfo from IndexInfo<K, V> to IndexInfo<V>
- Index name is now always String type (decoded with StringCodec)
- Updated all ftInfo method signatures across all command interfaces
- Updated IndexInfoParser to decode index name as String
- Updated all tests to use new signature
- Removed IndexInfoParserUnitTests (integration tests provide better coverage)

All integration tests passing (testFtInfoCommand*)
- Handle case where parseListValue already parsed ComplexData into List
- Add support for String values in parseLong, parseDouble, and parseBoolean methods
- Fix parsing of field flags when SORTABLE has a flag as its value (e.g., SORTABLE NOSTEM)
- Update getBoolean to decode non-String flag values using decodeStringAsString
- Add isFieldFlag helper method to identify known field flags
@tishun
Copy link
Copy Markdown
Collaborator

tishun commented Feb 27, 2026

@a-TODO-rov went over the review and did some polishing myself:

  • added @since anntations for 7.5
  • fixed a few minor bugs in the parser
  • executed the apigenerator to include the interface everywhere (was missing 2 files)
  • etc.

IMHO we are good to go

@jit-ci
Copy link
Copy Markdown

jit-ci Bot commented Feb 27, 2026

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

private IndexInfo.TextField<V> createTextField(V identifier, V attribute, boolean sortable, boolean unNormalizedForm,
boolean noIndex, boolean indexEmpty, boolean indexMissing, Map<String, Object> attributeMap,
Map<String, Object> additionalFields) {
Double weight = parseDouble(attributeMap.get(FLAG_WEIGHT));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

TextField weight always 0.0, never null when absent

Medium Severity

createTextField uses parseDouble(attributeMap.get(FLAG_WEIGHT)) which returns primitive double (defaulting to 0.0 when the key is absent). This gets autoboxed to Double.valueOf(0.0), so TextField.getWeight() never returns null — contradicting its documented contract of "or null if not set." The getDouble helper method already exists and correctly returns null for missing keys, so it looks like it was meant to be used here instead of parseDouble.

Additional Locations (1)

Fix in Cursor Fix in Web

&& !key.equals(FLAG_NOINDEX) && !key.equals(FLAG_INDEXEMPTY) && !key.equals(FLAG_INDEXMISSING)) {
vectorAttributes.put(key, entry.getValue());
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

RESP3 flags key leaks into vector attributes

Low Severity

In createVectorField, the exclusion list when building vectorAttributes does not include ATTR_FLAGS ("flags"). In RESP3, the attribute map contains a flags key with a List value (e.g., ["SORTABLE", "NOINDEX"]). This list is incorrectly included in vectorAttributes alongside actual vector attributes like DIM and DISTANCE_METRIC, polluting the map that VectorField.getAttributes() returns to callers.

Fix in Cursor Fix in Web

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