pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: jkatz (@jkatz) <noreply+jkatz@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #259: Understanding HNSW + filtering
Date: Tue, 12 Sep 2023 18:34:45 +0000
Message-ID: <gh-pgvector-pgvector-259-c1716230388@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-259@github.com>
References: <gh-pgvector-pgvector-259@github.com>

One thought around this specific to HNSW: perhaps there's a way towards a "multi-column" style index that would require more links, but allow for this type of query.

Let's say I have two columns: `embedding` and `category_id` and I choose to index both of them with a `hnsw` index. During the index creation, I would build out two different kinds of neighborhoods:

1. Neighborhoods around `embedding`
2. Neighborhoods around a `category_id` and `embedding` pair

When I have a `category_id` in my query, I then know to traverse the links that are around `category_id`/`embedding` pairs that have the same `embedding`. Otherwise, if I just have `embedding`, I would traverse any link.

This would increase index size + construction time, which is no different than multi-column indexes, and would may require an expansion of the on-disk format, this would allow you to trim down the pages you need to search on a particular filter.

view thread (90+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-259-c1716230388@github.com>
Permalink:  ../gh-pgvector-pgvector-259-c1716230388@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox