Class IndexFlatL2

IndexFlatL2 Index. IndexFlatL2 that stores the full vectors and performs squared L2 search.

Param

The dimensionality of index.

Hierarchy

Accessors

  • get codeSize(): number
  • Byte size of each encoded vector.

    Returns number

  • get codes(): Buffer
  • Encoded dataset, size ntotal * codeSize.

    Returns Buffer

  • get dims(): number
  • Returns number

    The dimensionality of vectors.

  • get ids(): BigInt[]
  • Vector identifiers, size ntotal.

    Returns BigInt[]

  • get indexType(): IndexType
  • Returns IndexType

    The type of index.

  • get isTrained(): boolean
  • returns a boolean that indicates whether training is required.

    Returns boolean

    Whether training is required.

  • get metricArg(): number
  • Returns number

    Argument of the metric type.

  • get metricType(): MetricType
  • Returns MetricType

    The metric of the index.

  • get ntotal(): number
  • Returns number

    The number of verctors currently indexed.

Methods

  • Add n vectors of dimension d to the index. Vectors are implicitly assigned labels ntotal .. ntotal + n - 1

    Parameters

    • x: number[]

      Input matrix, size n * d

    Returns void

  • Add n vectors of dimension d to the index using the provided labels.

    Parameters

    • x: number[]

      Input matrix, size n * d

    • y: (number | BigInt)[]

      Vector identifiers

    Returns void

  • Add n vectors of dimension d to the index with ID's.

    Parameters

    • x: number[]

      Input matrix, size n * d

    • ids: BigInt[]

      Vector identifiers

    Returns void

  • Free all resources associated with the index. Further calls to the index will throw.

    Returns void

  • Return buffer codes for a given byte range.

    Parameters

    • Optional start: number

      position to read from (default: 0).

    • Optional end: number

      position to read to (default: length).

    Returns Buffer

    Buffer containing the requested codes by range.

  • Merge the current index with another IndexFlatL2 instance.

    Parameters

    • otherIndex: IndexFlatL2

      The other IndexFlatL2 instance to merge from.

    Returns void

  • Reconstruct desired vector from index. Will throw if not supported by the index type.

    Parameters

    • key: number | BigInt

      Key of vector to reconstruct.

    Returns number[]

    Reconstructed vector of length dims.

  • Reconstruct a batch of vectors from index. Will throw if not supported by the index type.

    Parameters

    • keys: (number | BigInt)[]

    Returns number[]

    Reconstructed vector of length dims.

  • Remove IDs from the index.

    Parameters

    • ids: BigInt[]

      IDs to read.

    Returns number

    number of IDs removed.

  • Query n vectors of dimension d to the index. return at most k vectors. If there are not enough results for a query, the result array is padded with -1s.

    Parameters

    • x: number[]

      Input vectors to search, size n * d.

    • k: number

      The number of nearest neighbors to search for.

    Returns SearchResult

    Output of the search result.

  • Overwrite the codes using a custom buffer.

    Parameters

    • buffer: Buffer

      data to replace codes with.

    • Optional start: number

      position to write to (default: 0).

    Returns any

  • Train n vectors of dimension d to the index. Vectors are implicitly assigned labels ntotal .. ntotal + n - 1

    Parameters

    • x: number[]

      Input matrix, size n * d

    Returns void

  • Write index to a file.

    Parameters

    • fname: string

      File path to write.

    Returns void

  • Construct an index from factory descriptor.

    Parameters

    • dims: number

      Buffer to create index from.

    • descriptor: string

      Factory descriptor.

    • Optional metric: MetricType

      Metric type (defaults to L2).

    Returns Index

    The index read.

Generated using TypeDoc