Skip to content

Add search records #639

@KallynGowdy

Description

@KallynGowdy

Currently, CasualOS provides no way to search over data records. Search records are records that enable general purpose search capabilities via the records system.

Search records provide generalized search capabilities through Typesense, an open source search solution. Each search record represents a collection of JSON documents that are stored in Typesense.

They have the following signature:

interface SearchRecord {
    /**
     * The name of the record that the search record is stored in.
     */
    recordName: string;

    /**
     * The address of the search record.
     */
    address: string;

    /**
     * The markers which are applied to the search record.
     * These determine who is allowed to perform searches and add documents.
     */
    markers: string[];

    /**
     * The schema of documents in the record.
     */
    schema: {
        [key: string]: {
            /**
             * The type of the field.
             */
            type: 'string' | 'string[]' | 'int32' | 'int32[]' | 'int64' | 'int64[]' | 'float' | 'float[]' | 'bool' | 'bool[]' |
                'geopoint' | 'geopoint[]' | 'geopolygon' | 'object' | 'object[]' | 'string*' | 'image' | 'auto';

            /**
             * Enables faceting on the field.
             * 
             * Defaults to `false`.
             */
            facet?: boolean;

            /**
             * When set to `true`, the field can have empty, null or missing values. Default: `false`.
             */
            optional?: boolean;

            /**
             * When set to `false`, the field will not be indexed in any in-memory index (e.g. search/sort/filter/facet). Default: `true`.
             */
            index?: boolean;

            /**
             * When set to `false`, the field value will not be stored on disk. Default: `true`.
             */
            store?: boolean;

            /**
             * When set to true, the field will be sortable. Default: `true` for numbers, `false` otherwise.
             */
            sort?: boolean;

            /**
             * When set to `true`, the field value can be infix-searched. Incurs significant memory overhead. Default: `false`.
             */
            infix?: boolean;

            /**
             * For configuring language specific tokenization, e.g. `jp` for Japanese. Default: `en` which also broadly supports most European languages.
             */
            locale?: string;

            /**
             * Not currently supported.
             * 
             * Set this to a non-zero value to treat a field of type `float[]` as a vector field.
             */
            num_dim?: number;

            /**
             * Not currently supported.
             * 
             * The distance metric to be used for vector search. Default: `cosine`. You can also use `ip` for inner product.
             */
            vec_dist?: boolean;

            /**
             * Not currently supported.
             * Reserved for when/if references are supported.
             * Name of a field in another collection that should be linked to this collection so that it can be joined during query.
             */
            reference?: string;
            
            /**
             * Not currently supported.
             * 
             * Enables an index optimized for range filtering on numerical fields (e.g. rating:>3.5). Default: `false`.
             */
            rangeIndex?: boolean;

            /**
             * Not currently supported.
             * 
             * Values are stemmed before indexing in-memory. Default: `false`.
             */
            stem?: boolean;
        }
    }
}

Search records have the following API functions:

  • record - Standard
  • erase - Standard
  • get - Standard
  • list - Standard
  • listByMarker - Standard
  • storeDocument - Stores/updates a document in the search record.
  • eraseDocument - Deletes a document from the search record.
  • sync - Requests that data records be automatically synced to the search record.
  • listSyncs - Lists the automatic sync jobs for the search record.
  • unsync - Requests that data records no longer be synced.

Each search record has its own unique API key that allows the user to search over the record via using the Typesense API directly. Additionally, there's a public API key that can be used to search over all public collections.

Metadata

Metadata

Assignees

Labels

area:backendIs related to the backend server. (Everything in aux-records and aux-server/aux-backend)area:runtimeIs related to the CasualOS runtime. (Everything in aux-runtime, aux-common, aux-vm, etc.)enhancementNew feature or request

Projects

Status

In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions