Comments (5)
Using the containment operator (@>) for equality should speed up metadata filtering
thanks!
use jsonb_path_ops for a smaller index size. "The non-default GIN operator class jsonb_path_ops does not support the key-exists operators, but it does support @>, @? and @@."
vecs doesn't support key exists filters so that sounds great
--
how does #12 look, does that address both the way you expected?
from vecs.
Just realized it probably shouldn't use containment if the query is a list/tuple or dict, since both the following are true but not equal:
SELECT '{"a": [1, 2, 3]}'::jsonb @> '{"a": [1]}';
SELECT '{"a": {"b": 1, "c": 2}}'::jsonb @> '{"a": {"b": 1}}';
Edit: It could use containment so the index is used, but should also recheck for equality.
from vecs.
Great! fwiw, it could be done in SQL with:
WHERE metadata @> '{"a": [1, 2]}' AND metadata -> 'a' = '[1, 2]'
from vecs.
Yeah, looks great!
from vecs.
makes sense, thanks
I added tests for the various edge cases to make sure its all working properly
The trouble with re-checking for equality in python after the results are returned is that it makes it difficult to get the exact number of results the user requested without potentially fetching more matches from the database. To avoid that, the containment optimization is limited to when the user provides a single value e.g. 6
or "abc"
.
from vecs.
Related Issues (20)
- Feature Request: $in operator HOT 1
- Support pg_embedding HOT 2
- Openai Example on documentation doesn't seem to work well. HOT 9
- What is the relationship between SupabaseVectorStore integrated with langchain and this library HOT 1
- Support HNSW indexes
- Clarify Request for Support Policy HOT 2
- Empty Description on PyPI HOT 1
- Option to load private models from Higgingface HOT 2
- Add `ef_construction` and `m` as optional parameters when building HSNW index HOT 3
- Enable schema in client's parameters HOT 6
- Support for Metadata Projection HOT 1
- Explain Query Method HOT 1
- Deleting with filters not working (Package mismatch with source code?) HOT 1
- can't add to an existing table HOT 6
- Remove limit of 1 entry per filter HOT 3
- Adding another column in collections to store raw text HOT 2
- Feature Request: Adding a function to clear the table HOT 1
- str object is not callable HOT 5
- FATAL: Max client connections reached HOT 1
- `$in` operator doesn't seem to work HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vecs.