-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
collection.query() should return all elements if n_results is greater than the total number of elements in the collection #301
Comments
Why didn't the authorities fix the problem |
Great point @fritzprix - this is being worked on upstream inside You can check |
Hi, I am new here and want to contribute to this issue, I have found that the above error is thrown by the 'get_nearest_neighbours' function. So can I edit the function setting the value of k to size of collection if it exceeds the size of collection? and One more question can my questions be seen by the authors of the Repo? and if not then how can I reach them? Thank you for any help you can provide |
the code above raises exception complaining
I think this should fail in more graceful way and can be resolved with this issue#301. if |
while this is an issue, the solution is pretty much a oneliner: # Query the collection to get the 5 most relevant results
count = collection.count()
results = collection.query(query_texts=[query],
n_results=min(5, count) # here is the fix
) |
…reater than total number of elements (#360) ## Description of changes FIXES [collection.query() should return all elements if n_results is greater than the total number of elements in the collection. #301 ](#301) - Improvements & Bug fixes - added Check Number of requested results before calling knn_query. - n_result <= max_element - n_result > 0 - collection.query() returns all elements if n_results is greater than the total number of elements in the collection. ## Documentation Changes Bugfix, no doc change required. --------- Co-authored-by: hammadb <hammad@trychroma.com>
The current version of chromadb handle the case of `n_result` is greater than the total number of elements in the collection. [chromadb PR](chroma-core/chroma#301). So removed `NotEnoughElementException` that doesn't exists now. #### Who can review? Tag maintainers/contributors who might be interested: - @hwchase17 - @dev2049
the code above raises exception complaining n_results is greater than total number of elements in given collection
I think this should fail in more graceful way.
if number of elements < n_results, then all elements can be returned instead of raise exception. otherwise, at least, there should be sensible way to check the number of elements prior to call query()
The text was updated successfully, but these errors were encountered: