Skip to content

Adds QueryBuilder to MongoDBAtlasDocumentIndex#1891

Merged
JoanFM merged 5 commits into
docarray:mainfrom
caseyclements:mongodb-querybuilder
Jun 6, 2024
Merged

Adds QueryBuilder to MongoDBAtlasDocumentIndex#1891
JoanFM merged 5 commits into
docarray:mainfrom
caseyclements:mongodb-querybuilder

Conversation

@caseyclements

Copy link
Copy Markdown
Contributor

Description

This pull request adds QueryBuilder functionality to the existing MongoDBAtlasDocumentIndex.

Example Usage

from docarray.index import MongoAtlasDocumentIndex
import numpy as np

NDIM = 10

class MyDoc(BaseDoc):
    text: str
    embedding: NdArray[NDIM]
    number: int

docs = [MyDoc(text=f'text {i}', embedding=np.random.randn(NDIM), number=i) for i in range(5)]
index = MongoAtlasDocumentIndex[MyDoc](mongo_connection_uri='localhost')
index.index(docs)
    query = (
        index.build_query()
        .find(query=np.ones(NDIM), search_field='embedding')
        .filter(query={"number": {"$gt": 0}})
        .text_search(query="text 3", search_field='text')
        .build(limit=n_docs)

Supported Functionality

Atlas offers full-text, vector, and hybrid search.
For documentation, see the following.

Integration Tests and documentation

  • tests/index/mongo_atlas
  • docs/API_reference/doc_index/backends/mongodb.md

Signed-off-by: Casey Clements <casey.clements@mongodb.com>
Signed-off-by: Casey Clements <casey.clements@mongodb.com>
Signed-off-by: Casey Clements <casey.clements@mongodb.com>
Comment thread tests/index/mongo_atlas/__init__.py Outdated

@WaVEV WaVEV left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, I only left an optional comment. Nice work so far

Signed-off-by: Casey Clements <casey.clements@mongodb.com>
Signed-off-by: Casey Clements <casey.clements@mongodb.com>
@caseyclements

Copy link
Copy Markdown
Contributor Author

Hi @JoanFM. When you have a minute, would you please merge this PR? Thank you for working with us on this. It has been fun. We will add more after upcoming Atlas releases.

@JoanFM JoanFM merged commit b816ab9 into docarray:main Jun 6, 2024
@caseyclements

Copy link
Copy Markdown
Contributor Author

@JoanFM, thank you!

@JoanFM

JoanFM commented Jun 6, 2024

Copy link
Copy Markdown
Member

Thank you @caseyclements for the contribution, soon will release a new version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants