Skip to content

filter_by is causing a type error when checking for equality on a field with type string[] #10

@lewisedc

Description

@lewisedc

filter_by is causing a type error when checking for equality on a field with type string[], despite providing valid results when run.

Example setup:

import { collection, setDefaultConfiguration } from "typesense-ts";

setDefaultConfiguration({
  apiKey: "xyz",
  nodes: [{ url: "http://localhost:8108" }],
});

const booksSchema = collection({
  name: "books",
  fields: [
    { name: "title", type: "string" },
    { name: "authors", type: "string[]" },
  ],
});

First example filter_by:

await booksSchema.search({
  q: "*",
  query_by: [],
  filter_by: "authors:=William",
});

Type error: Argument of type '{ q: string; query_by: never[]; filter_by: string; }' is not assignable to parameter of type '"[Error on filter_by]: Invalid token sequence: identifier with name `authors` followed by `:=`"'.ts(2345)

Second example filter_by:

await booksSchema.search({
  q: "*",
  query_by: [],
  filter_by: "authors:=[William]",
});

Type error: Argument of type '{ q: string; query_by: never[]; filter_by: string; }' is not assignable to parameter of type '"[Error on filter_by]: Unknown token: ["'.ts(2345)

Third example filter_by:

await booksSchema.search({
  q: "*",
  query_by: [],
  filter_by: "authors:=William Shakespeare",
});

Type error: Argument of type '{ q: string; query_by: never[]; filter_by: string; }' is not assignable to parameter of type '"[Error on filter_by]: Invalid token sequence: Literal Token `William` followed by literal token"'.ts(2345)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions