workerd icon indicating copy to clipboard operation
workerd copied to clipboard

🐛 BUG: In Vectorize filter by metadata keys not working.

Open PrithivirajDamodaran opened this issue 2 years ago • 3 comments

Which Cloudflare product(s) does this pertain to?

Workers for Platforms, Workers Runtime

What version(s) of the tool(s) are you using?

3.15.0

What version of Node are you using?

v18.17.1.

What operating system are you using?

Mac and Linux

Describe the Bug

I am using Vectorize for indexing and querying vectors but it works only query by vectors. But attribute filter is a common for most use-case we should be able to filter by one or more metadata keys and apply query vectors. Thats not working. I cant see any documentation to do the same. Whats the syntax I checked CLIs , JS and API docs none of them seem to show.

In this case query by vectors (on values) and filter by price or description.

{
    id: "97913813",
    values: [0.16, 1.2, 3.8],
    metadata: { "description": "DSLR camera", "price": 13.99$ },
  },

I am sure this feature is included as it is a 1st class feature for DBs, So I assume this to be a omission in the documentation by mistake ?

let queryVector = [54.8, 5.5, 3.1];
let matches = await env.YOUR_INDEX.query(queryVector, { topK: 1, returnValues: true, returnMetadata: true })

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

PrithivirajDamodaran avatar Nov 10 '23 03:11 PrithivirajDamodaran

Transferring this to workerd since it's a feature request for the Vectorize JS API cc @vy-ton

penalosa avatar May 01 '24 17:05 penalosa

@PrithivirajDamodaran You can add a filter property when calling query(), see example here

vy-ton avatar May 10 '24 13:05 vy-ton

@vy-ton linked example no longer shows how to use filters. Can't find any such example.

jesper-bylund avatar Oct 21 '24 13:10 jesper-bylund