Docs: explain how to use Vector Search maxResultCount combined with additional criteria #658
Open
1 task done
Labels
documentation
Improvements or additions to documentation
Uh oh!
There was an error while loading. Please reload this page.
Is there an existing issue?
Build info
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.
The text was updated successfully, but these errors were encountered: