Options
All
  • Public
  • Public/Protected
  • All
Menu

A client for the RediSearch module. It abstracts the API of the module and lets you just use the engine

Type parameters

  • C: Redis

Hierarchy

  • Client

Index

Constructors

constructor

  • new Client(indexName: string, conn: C): Client

Properties

Private indexName

indexName: string

redis

redis: C

Methods

_addDocument

  • _addDocument<T>(conn: Redis | null, docId: string, fields: T, score?: DocumentScore, payload?: Object, noSave?: boolean, replace?: boolean, partial?: boolean): Promise<"OK">
  • Type parameters

    Parameters

    • conn: Redis | null
    • docId: string
    • fields: T
    • Default value score: DocumentScore = 1
    • Optional payload: Object
    • Default value noSave: boolean = false
    • Default value replace: boolean = false
    • Default value partial: boolean = false

    Returns Promise<"OK">

addDocument

  • addDocument<T>(docId: string, fields: T, score?: DocumentScore, payload?: Object, noSave?: boolean, replace?: boolean, partial?: boolean): Promise<"OK">
  • Add a single document to the index.

    Type parameters

    Parameters

    • docId: string

      the id of the saved document.

    • fields: T

      object of the document fields to be saved and/or indexed. NOTE: Geo points should be encoded as strings of "lon,lat"

    • Default value score: DocumentScore = 1

      the document ranking, between 0.0 and 1.0

    • Optional payload: Object

      optional inner-index payload we can save for fast access in scoring functions

    • Default value noSave: boolean = false

      if set to true, we just index the document, and don't save a copy of it. This means that searches will just return ids.

    • Default value replace: boolean = false

      if true, and the document already is in the index, we perform an update and reindex the document

    • Default value partial: boolean = false

      if true, the fields specified will be added to the existing document. This has the added benefit that any fields specified with no_index will not be reindexed again. Implies replace

    Returns Promise<"OK">

batchIndexer

  • Create a new batch indexer from the client with a given chunk size

    Parameters

    • Default value chunkSize: number = 1000

    Returns BatchIndexer

createIndex

  • createIndex(fields: Field[]): Promise<"OK">
  • Create the search index. Creating an existing index juts updates its properties

    Parameters

    • fields: Field[]

      a list of TextField or NumericField objects

    Returns Promise<"OK">

dropIndex

  • dropIndex(): Promise<"OK">
  • Drop the index if it exists

    Returns Promise<"OK">

search

  • search<T, S>(queryOrString: Query | string, snippetSizes?: S): Promise<Result<T, S>>
  • Search the index for a given query, and return a result of documents

    Type parameters

    • T

    • S

    Parameters

    • queryOrString: Query | string

      the search query. Either a text for simple queries with default parameters, or a Query object for complex queries. See RediSearch's documentation on query format

    • Optional snippetSizes: S

      A dictionary of {field: snippet_size} used to trim and format the result. e.g. {'body': 500}

    Returns Promise<Result<T, S>>

Private toQuery

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc