Skip to content

Commit c44c5f0

Browse files
Describe binary \ vector in readme
1 parent 3a611ef commit c44c5f0

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

README.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ const studioSchema = new Schema(Studio, {
222222
})
223223
```
224224

225-
When you create a `Schema`, it modifies the entity you handed it, adding getters and setters for the properties you define. The type those getters and setters accept and return are defined with the type parameter above. Valid values are: `string`, `number`, `boolean`, `string[]`, `date`, `point`, or `text`.
225+
When you create a `Schema`, it modifies the entity you handed it, adding getters and setters for the properties you define. The type those getters and setters accept and return are defined with the type parameter above. Valid values are: `string`, `number`, `boolean`, `string[]`, `date`, `point`, `text` or `binary`.
226226

227227
The first three do exactly what you think—they define a property that is a [String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String), a [Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number), or a [Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean). `string[]` does what you'd think as well, specifically defining an [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) of Strings.
228228

@@ -236,17 +236,20 @@ const point = { longitude: 12.34, latitude: 56.78 }
236236

237237
A `text` field is a lot like a `string`. If you're just reading and writing objects, they are identical. But if you want to *search* on them, they are very, very different. I'll cover that in detail when I talk about [using RediSearch](#-using-redisearch) but the tl;dr is that `string` fields can only be matched on their whole value—no partial matches—and are best for keys while `text` fields have full-text search enabled on them and are optimized for human-readable text.
238238

239+
A `binary` field is a binary blob of data using a `Buffer` object. For Hash data structures it will be stored as a binary field in Redis, for JSON data structures it will be serialized to a Base64 string. The `binary` field stored in a Hash data structure can be indexed as a [Vector Similarity](https://redis.io/docs/stack/search/reference/vectors/) field. When stored in a JSON data structure it will be automatically unindexed.
240+
239241
Additional field options can be set depending on the field type. These correspond to the [Field Options](https://redis.io/commands/ft.create/#field-options) avialable when creating a RediSearch full-text index. Other than the `separator` option, these only affect how content is indexed and searched.
240242

241-
| schema type | RediSearch type | `indexed` | `sortable` | `normalized` | `stemming` | `phonetic` | `weight` | `separator` | `caseSensitive` |
242-
| -------------- | :-------------: | :-------: | :--------: | :----------: | :--------: | :--------: | :------: | :---------: | :-------------: |
243-
| `string` | TAG | yes | HASH Only | HASH Only | - | - | - | yes | yes |
244-
| `number` | NUMERIC | yes | yes | - | - | - | - | - | - |
245-
| `boolean` | TAG | yes | HASH Only | - | - | - | - | - | - |
246-
| `string[]` | TAG | yes | HASH Only | HASH Only | - | - | - | yes | yes |
247-
| `date` | NUMERIC | yes | yes | - | | - | - | - | - |
248-
| `point` | GEO | yes | - | - | | - | - | - | - |
249-
| `text` | TEXT | yes | yes | yes | yes | yes | yes | - | - |
243+
| schema type | RediSearch type | `indexed` | `sortable` | `normalized` | `stemming` | `phonetic` | `weight` | `separator` | `caseSensitive` | `vector` |
244+
| -------------- | :-------------: | :-------: | :--------: | :----------: | :--------: | :--------: | :------: | :---------: | :-------------: | :------: |
245+
| `string` | TAG | yes | HASH Only | HASH Only | - | - | - | yes | yes | - |
246+
| `number` | NUMERIC | yes | yes | - | - | - | - | - | - | - |
247+
| `boolean` | TAG | yes | HASH Only | - | - | - | - | - | - | - |
248+
| `string[]` | TAG | yes | HASH Only | HASH Only | - | - | - | yes | yes | - |
249+
| `date` | NUMERIC | yes | yes | - | - | - | - | - | - | - |
250+
| `point` | GEO | yes | - | - | - | - | - | - | - | - |
251+
| `text` | TEXT | yes | yes | yes | yes | yes | yes | - | - | - |
252+
| `binary` | VECTOR | yes | - | - | - | - | - | - | - | yes |
250253

251254
* `indexed`: true | false, whether this field is indexed by RediSearch (default true)
252255
* `sortable`: true | false, whether to create an additional index to optmize sorting (default false)
@@ -256,6 +259,7 @@ Additional field options can be set depending on the field type. These correspon
256259
* `weight`: number, the importance weighting to use when ranking results (default 1)
257260
* `separator`: string, the character to delimit multiple tags (default '|')
258261
* `caseSensitive`: true | false, whether original letter casing is kept for search (default false)
262+
* `vector`: object containing [Vector Similarity](https://redis.io/docs/stack/search/reference/vectors/) configuration
259263

260264
Example showing additional options:
261265

@@ -269,6 +273,7 @@ const commentSchema = new Schema(Comment, {
269273
approved: { type: 'boolean', indexed: false },
270274
iphash: { type: 'string', caseSensitive: true },
271275
notes: { type: 'string', indexed: false },
276+
image: { type: 'binary', vector: { algorithm: 'FLAT', dim: 512, distance_metric: 'COSINE' } },
272277
})
273278
```
274279

0 commit comments

Comments
 (0)