Query Module#

Note

If you haven’t yet, please check the section How to configure your auth key before running the code snippets in this page.

The Query module is built to consume existing collections on your Jai environment.

The methods of this module are exclusively to consume existing collections in Jai.

For more information, see the full Query class reference.

Query#

Bellow, a simple example to instantiate the Query class:

>>> from jai import Query
...
>>> q = Query(name)

similar#

Performs a similarity search in the collection.

Data can be raw data or a set of ids. If it’s a set of ids, the ids must exist in the collection.

>>> from jai import Query
...
>>> q = Query(name)
>>> q.similar(data)

recommendation#

This is only available for Recommendation type databases.

Performs a recommendation search in the collection.

Data can be raw data or a set of ids. If it’s a set of ids, the ids must exist in the collection.

Returns the ids of the database selected, therefore the data/ids input must be from the twin database.

>>> from jai import Query
...
>>> q = Query(name)
>>> q.recommendation(data)

predict#

This is only available for Supervised type databases. Perform a prediction to the raw data.

>>> from jai import Query
...
>>> q = Query(name)
>>> q.predict(data)

fields#

Return information about the fields that are expected as input.

>>> from jai import Query
...
>>> q = Query(name)
>>> q.fields()

download_vectors#

Returns an array with the vectors from the database.

>>> from jai import Query
...
>>> q = Query(name)
>>> q.download_vectors()

filters#

Returns the list of filters if any.

>>> from jai import Query
...
>>> q = Query(name)
>>> q.filters()

ids#

Returns the list of ids in the database.

>>> from jai import Query
...
>>> q = Query(name)
>>> q.ids()

Inherited from TaskBase#

name#

This attribute contains the value of the database’s name.

>>> from jai import Query
...
>>> q = Query(name)
>>> q.name

db_type#

This attribute returns the type of the database.

>>> from jai import Query
...
>>> q = Query(name)
>>> q.db_type

is_valid#

This method returns a boolean indicating if the database exists or not.

>>> from jai import Query
...
>>> q = Query(name)
>>> q.is_valid()

describe#

This method returns the full configuration information of the database.

>>> from jai import Query
...
>>> q = Query(name)
>>> q.describe()