Skip to main content

Data Types

Tigris supports all of the TypeScript types while also providing support for custom types via classes.

Strings

@TigrisSearchIndex("post")
export class Post {
@SearchField()
title: string;

@SearchField({ sort: true, facet: true })
author: string;
}

Boolean

@TigrisSearchIndex("post")
export class Post {
@SearchField()
pinned: boolean;

@SearchField({ sort: true, facet: true })
active: boolean;
}

Numbers

@TigrisSearchIndex("post")
export class Post {
@SearchField({ sort: true, facet: true })
viewCount: number;

@SearchField({ facet: true })
authorId: bigint;
}

Javascript number type can only represent integer values from -9007199254740991 to 9007199254740991. If your collection field has a use-case for 64-bit integers, we recommend using bigint or string field type to represent your integers.

Dates

@TigrisSearchIndex("post")
export class Post {
@SearchField({ sort: true })
publishedAt: Date;
}

Objects

User-defined classes and objects are supported. Fields can be of any type, there is no restriction.

export class Bio {
@SearchField()
text: string;

@SearchField({ sort: true })
createdAt: Date;
}

@TigrisSearchIndex("authors")
export class Author {
@SearchField()
bio: Bio;
}

Arrays

Arrays of all the above types are supported. There is no restriction.

@TigrisSearchIndex("post")
export class Post {
@SearchField({ elements: TigrisDataTypes.STRING, facet: true })
tags: string[];

@SearchField({ elements: Comment })
comments: Comment[];
}

Vectors

Tigris supports storing vector embeddings and vector search. Vectors are represented as arrays of numbers.

// 1536 floats total for ada-002
@SearchField({ dimensions: 1536 })
vector: number[];

Sorting and Faceting

Tigris supports the majority of the primitive TypeScript types while also providing support for custom types.

TypeSortFacet
stringyesyes
booleanyesyes
numberyesyes
bigintyesyes
dateyesno
objectyesyes
arraynoyes
note

In case of an object type field, sort and facet properties apply to its nested fields. The above rules also apply to user-defined class.

id Field

Tigris allows you to tag a field to be used for the document id. This field is used to uniquely identify a document in the search index. The field must be of type string.

@SearchField({ id: true })
catalogId: string;