redis-vl-dotnet

Field Definitions

RedisVL supports text, tag, numeric, geo, and vector field definitions. Each field type maps directly onto RediSearch schema capabilities while keeping validation in .NET code.

Supported field types

Type Purpose

TextFieldDefinition

Full-text search fields with options such as stemming, phonetics, weighting, suffix tries, and sortable behavior.

TagFieldDefinition

Exact-match or set-style categorical fields with configurable separators and case sensitivity.

NumericFieldDefinition

Numeric range and sortable fields.

GeoFieldDefinition

Geographic coordinates for geo filters.

VectorFieldDefinition

Dense vector fields with FLAT, HNSW, or SVS-VAMANA indexing attributes.

Text, tag, numeric, and geo options

Common field options:

  • name is required for every field

  • alias lets Redis index the field under a different name

  • sortable is available on text, tag, numeric, and geo fields

Additional options by type:

  • text: noStem, phoneticMatch, weight, withSuffixTrie, indexMissing, indexEmpty, noIndex, unNormalizedForm

  • tag: separator, caseSensitive, withSuffixTrie, indexMissing, indexEmpty, noIndex

  • numeric: indexMissing, noIndex, unNormalizedForm

  • geo: indexMissing, noIndex

Validation rules enforced by the library:

  • NOINDEX fields must also be sortable on text, tag, numeric, and geo fields

  • UNF can only be enabled on sortable text and numeric fields

  • tag separators must be a single non-whitespace character

  • text weight must be greater than zero

Vector fields

Vector fields use VectorFieldDefinition plus VectorFieldAttributes:

new VectorFieldDefinition(
    "embedding",
    new VectorFieldAttributes(
        VectorAlgorithm.Hnsw,
        VectorDataType.Float32,
        VectorDistanceMetric.Cosine,
        dimensions: 1536,
        initialCapacity: 1000,
        m: 16,
        efConstruction: 200,
        efRuntime: 10))

Supported vector attributes:

  • algorithm: Flat, Hnsw, or SvsVamana

  • dataType: Float32, Float64, Float16, BFloat16, UInt8, or Int8

  • distanceMetric: Cosine, L2, or InnerProduct

  • dimensions: required and must be greater than zero

  • initialCapacity, blockSize: optional tuning knobs for any algorithm

  • HNSW-only: m, efConstruction, efRuntime

  • HNSW and SVS-VAMANA: epsilon (range-query approximation factor)

  • SVS-VAMANA-only: compression, constructionWindowSize, graphMaxDegree, searchWindowSize, trainingThreshold, reduce

SVS-VAMANA with vector compression

SVS-VAMANA is a graph-based index that supports vector compression (LVQ and LeanVec) to reduce memory usage:

new VectorFieldDefinition(
    "embedding",
    new VectorFieldAttributes(
        VectorAlgorithm.SvsVamana,
        VectorDataType.Float16,
        VectorDistanceMetric.Cosine,
        dimensions: 1536,
        compression: VectorCompression.Lvq8,
        constructionWindowSize: 250,
        graphMaxDegree: 40,
        searchWindowSize: 20))

VectorCompression values: None (default), Lvq8, Lvq4, Lvq4x4, Lvq4x8, LeanVec4x8, LeanVec8x8. The reduce attribute sets the reduced dimension count for LeanVec compression.

At query time, SVS-VAMANA KNN queries accept their own runtime knobs through VectorKnnRuntimeOptions:

var runtimeOptions = new VectorKnnRuntimeOptions(
    searchWindowSize: 30,
    useSearchHistory: SvsSearchHistory.On,
    searchBufferCapacity: 60);

Validation rules:

  • all numeric tuning values must be zero or greater

  • Flat does not allow HNSW-only or SVS-VAMANA-only settings

  • HNSW-only settings (m, efConstruction, efRuntime) are rejected on non-HNSW fields

  • SVS-VAMANA-only settings (compression, graph/window knobs) are rejected on non-SVS-VAMANA fields

  • EF_RUNTIME is only valid on HNSW fields; SEARCH_WINDOW_SIZE / USE_SEARCH_HISTORY / SEARCH_BUFFER_CAPACITY only on SVS-VAMANA fields

JSON and HASH document mapping

Field definitions work with both storage types, but the underlying document model differs:

  • JSON fields refer to properties inside RedisJSON documents

  • HASH fields refer to hash entries stored on the Redis key

That means the same field list can be expressed in both models, but document-loading and partial-update behavior follow the storage type chosen in IndexDefinition.

Example reference

Use /examples/JsonStorageExample/schema.yaml for a YAML-driven JSON example and /examples/VectorSearchExample for constructor-based HASH fields, including multiple vector definitions.