Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docarray/array/mixins/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def find(
elif isinstance(query, str) or (
isinstance(query, list) and isinstance(query[0], str)
):
result = self._find_by_text(query, index=index, **kwargs)
result = self._find_by_text(query, index=index, limit=limit, **kwargs)

if len(result) == 1:
return result[0]
Expand Down
10 changes: 9 additions & 1 deletion tests/unit/array/mixins/test_find.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def test_find_by_text(storage, config, start_storage):
assert isinstance(results, DocumentArray)
assert len(results) == 2
assert set(results[:, 'id']) == {'1', '3'}
results = da.find('token3 token4', limit=1)
assert len(results) == 1

results = da.find(['token4', 'token'])
assert isinstance(results, list)
Expand All @@ -109,7 +111,7 @@ def test_find_by_text(storage, config, start_storage):
('elasticsearch', {'n_dim': 32, 'tag_indices': ['attr1', 'attr2', 'attr3']}),
],
)
def test_find_by_tag(storage, config):
def test_find_by_tag(storage, config, start_storage):
da = DocumentArray(storage=storage, config=config)
da.extend(
[
Expand Down Expand Up @@ -146,6 +148,9 @@ def test_find_by_tag(storage, config):
assert results[0].id == '1'
assert results[1].id == '2'

results = da.find('token1 token2', index='attr1', limit=1)
assert len(results) == 1

results = da.find('token2 token4', index='attr1')
assert len(results) == 2
assert set(results[:, 'id']) == {'1', '3'}
Expand All @@ -159,6 +164,9 @@ def test_find_by_tag(storage, config):
assert results[0].id == '2'
assert results[1].id == '1'

results = da.find('token6', index='attr3', limit=1)
assert len(results) == 1

results = da.find('token5', index='attr3')
assert len(results) == 2
assert set(results[:, 'id']) == {'1', '3'}
Expand Down