[BUG] Chroma DB - similarity_search - chromadb.errors.NotEnoughElementsException
Facing the same issue. Is it possible to pass the minimum number of query results it can return from our end? Facing the same issue
Within the Chroma DB, similarity_search has a default "k" of 4.
However, if there are less than 4 results to return to the query, it will crash instead of returning whatever is available.


```similarity_search(query: str, k: int = 4, filter: Optional[Dict[str, str]] = None, **kwargs: Any) → List[langchain.docstore.document.Document][[source]](https://langchain.readthedocs.io/en/latest/_modules/langchain/vectorstores/chroma.html#Chroma.similarity_search)
Run similarity search with Chroma.

Parameters
query (str) – Query text to search for.

k (int) – Number of results to return. Defaults to 4.

filter (Optional[Dict[str, str]]) – Filter by metadata. Defaults to None.

Returns
List of documents most simmilar to the query text.

Return type
List[Document]
```

```
  raise NotEnoughElementsException(
chromadb.errors.NotEnoughElementsException: Number of requested results 4 cannot be greater than number of elements in index 1
```

I believe a check is needed to return whatever is available whenever the results are < k.

Edit: You can set `k=1` for the search, but then you are artificially limiting yourself, without knowing what is available.
It really should check if the N results returned are <= K, and if so, instead of crashing it should return whatever is availab.e.