@blackglory/fts-js
TypeScript icon, indicating that this package has built-in type declarations

0.8.3 • Public • Published

fts-js

Install

npm install --save @blackglory/fts-js
# or
yarn add @blackglory/fts-js

API

enum QueryKeyword {
  And = 0
, Or = 1
, Not = 2
, Phrase = 3
, Prefix = 4
}

type IQueryExpression =
| ITermExpression
| IPhraseExpression
| IPrefixExpression
| IAndExpression
| IOrExpression
| INotExpression

type ITermExpression = string
type IPhraseExpression = [
  QueryKeyword.Phrase
, ...IQueryExpression[]
]
type IPrefixExpression = [
  QueryKeyword.Prefix
, string
]
type IAndExpression = [
  IQueryExpression
, QueryKeyword.And
, IQueryExpression
]
type IOrExpression = [
  IQueryExpression
, QueryKeyword.Or
, IQueryExpression
]
type INotExpression = [
  QueryKeyword.Not
, IQueryExpression
]

interface IFTSClientOptions {
  server: string
  timeout?: number
  retryIntervalForReconnection?: number
}

class FTSClient {
  static create(options: IFTSClientOptions): Promise<FTSClient>

  close(): Promise<void>

  getNamespaceStats(namespace: string, timeout?: number): Promise<INamespaceStats>
  getBucketStats(namespace: string, bucket: string, timeout?: number): Promise<IBucketStats>

  getAllNamespaces(timeout?: number): Promise<string[]>
  getAllBuckets(namespace: string, timeout?: number): Promise<string[]>

  clearBucketsByNamespace(namespace: string, timeout?: number): Promise<void>
  clearDocumentsByBucket(namespace: string, bucket: string, timeout?: number): Promise<void>

  setDocument(
    namespace: string
  , bucket: string
  , documentId: string
  , lexemes: string[]
  , timeout?: number
  ): Promise<void>

  removeDocument(
    namespace: string
  , bucket: string
  , documentId: string
  , timeout?: number
  ): Promise<void>

  queryDocuments(
    namespace: string
  , expression: IQueryExpression
  , options?: {
      buckets?: string[]
      limit?: number
      offset?: number
    }
  , timeout?: number
  ): Promise<IDocumentQueryResult[]>
}

Readme

Keywords

none

Package Sidebar

Install

npm i @blackglory/fts-js

Weekly Downloads

4

Version

0.8.3

License

MIT

Unpacked Size

26.6 kB

Total Files

23

Last publish

Collaborators

  • black_glory