logo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readme
Files and versions

68 lines
2.9 KiB

# ANN Search Operator: MilvusClient
2 years ago
*author: junjie.jiangjjj*
<br />
## Desription
Search embedding in [Milvus](https://milvus.io/), **please make sure you have inserted data to Milvus Collection**.
<br />
## Code Example
> Please make sure you have inserted data into Milvus, refer to [ann_insert.milvus_client](https://towhee.io/ann-insert/milvus-client) and [load the collection](https://milvus.io/docs/v2.1.x/load_collection.md) to memory.
```python
from towhee import pipe, ops, DataCollection
2 years ago
p = pipe.input('text') \
.map('text', 'vec', ops.sentence_embedding.transformers(model_name='all-MiniLM-L12-v2')) \
.flat_map('vec', 'rows', ops.ann_search.milvus_client(host='127.0.0.1', port='19530', collection_name='text_db2', **{'output_fields': ['text']})) \
.map('rows', ('id', 'score', 'text'), lambda x: (x[0], x[1], x[2])) \
.output('id', 'score', 'text')
2 years ago
DataCollection(p('cat')).show()
# result:
```
```python
from towhee import pipe, ops
# search additional info url:
from towhee import pipe, ops, DataCollection
2 years ago
p = pipe.input('text') \
.map('text', 'vec', ops.sentence_embedding.transformers(model_name='all-MiniLM-L12-v2')) \
.map('vec', 'rows', ops.ann_search.milvus_client(host='127.0.0.1', port='19530', collection_name='text_db2', **{'output_fields': ['text']})) \
.output('rows')
2 years ago
DataCollection(p('cat')).show()
```
<br />
## Factory Constructor
Create the operator via the following factory method:
***ann_search.milvus_client(host='127.0.0.1', port='19530', collection_name='textdb')***
<br />
# More Resources
- [Tokopedia Achieved a 10x Smarter Search with Milvus](https://zilliz.com/customers/tokopedia): Indonesia's largest e-commerce platform, Tokopedia's quest for superior search functionality, led them to Milvus, a game-changer in semantic search.
- [Spring AI and Milvus: Using Milvus as a Spring AI Vector Store - Zilliz blog](https://zilliz.com/blog/spring-ai-and-milvus-using-milvus-as-spring-ai-vector-store): A comprehensive guide on how to use Milvus as a Spring AI vector store
- [ArXiv Papers Vector Similarity Search with Milvus 2.1 - Zilliz blog](https://zilliz.com/blog/Arxiv-scientific-papers-vector-similarity-search): Run semantic search queries on ~640K papers in <50ms using Dask, SBERT SPECTRE, and Milvus Vector database
- [Unlock Advanced Recommendation Engines with Milvus' New Range Search - Zilliz blog](https://zilliz.com/blog/unlock-advanced-recommendation-engines-with-milvus-new-range-search): Exploring Milvus’s newly released range search feature, how it differs from the traditional KNN search, and when to use it.
- [Milvus 2.4 Unveils Game-Changing Features for Enhanced Vector Search - Zilliz Newsroom; Milvus 2.4 Unveils Game-Changing Features for Enhanced Vector Search](https://zilliz.com/news/Milvus 2.4-Unveils-Game-Changing-Features-for-Enhanced-Vector-Search): Milvus 2.4 Unveils Game-Changing Features for Enhanced Vector Search