objectbox / objectbox/objectbox-dart
Docs: explain how to use Vector Search maxResultCount combined with additional criteria
Nobody has claimed this yet.
- Dominant language
- Dart
- Stars
- 1.2k
- Forks
- 162
- Avg merge
- 15m
- Merged PRs (30d)
- 1
Description
Is there an existing issue?
- I have searched existing issues
Build info
- objectbox version: [4.0.1]
- Flutter/Dart version: [Flutter 3.22.3, Dart 3.4.4]
- Build OS: [Windows 11]
- Deployment OS or device: [Android 10, API29, Huawei P30 Pro]
Steps to reproduce
TODO Tell us exactly how to reproduce the problem.
-
create a query for vector search, I did with embeddings, want to have 2 results:
final query = box
.query(Message_.embedding.nearestNeighborsF32(search_embedding, 2))
.build();
=> Works fine -
combine the search with a second criteria.
final query = box
.query(
Message_.embedding.nearestNeighborsF32(search_embedding, 2)
.and( Message_.chatid.equals(character))
).build();
=> Results given are 0 or 1 or 2 results. Expected are 2 results.
I assume that the first condition is fulfilled, it searches for 2 results independent of the second criteria. Then second criteria is applied and from 2 results only 1 or 0 or 2 remain.
Expected behavior
Find 2 results with vector search also with additional conditions.
Actual behavior
Amount of results vary, depending on if the found results of step 1 fulfill the second criteria or not.
Note after analysis
In your documentation the following I assume will also not work as expected:
https://docs.objectbox.io/on-device-vector-search
final query = box
.query(City_.location.nearestNeighborsF32(madrid, 2)
.and(City_.name.startsWith("B")))
.build();
Just figured out that I could probably use "limit" from here https://docs.objectbox.io/queries in the "query" and leave the limit out in the "vector search" (leave it out is not possible, I just set it to several million). Would just be a question to you how this will work regarding ressources, how the vector search is implemented, but assume that will work.
Another workaround for me might be to work with a stream and interrupt the stream after 2 results.
So it might not be a bug, maybe just the documentation above needs to be adopted.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the on-device vector search and queries documentation linked in the issue, comparing the nearest-neighbor count with an additional criterion and query limit. Update the documentation to explain the result-count behavior and the supported way to obtain the requested number of matching results. Done when the examples and resource implications are clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- databases, documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100