Search API

Search functionalities of the Vantage API

The Search API gives you the ability to perform different types of searches supported by the Vantage platform. Currently, we support four different types. For more details, you can check the Search page of our documentation.

📘

Vantage Client

In the following code blocks, we're initializing the Vantage client using Vantage API key. For more information on client configuration, check out the API Usage page.

Search API


Semantic Search

The following example demonstrates how to perform a semantic search over the collection example-collection.

For more details on how it works, visit our Semantic Search documentation page.

from vantage_sdk import VantageClient

vantage_instance = VantageClient.using_vantage_api_key(
    vantage_api_key=VANTAGE_API_KEY,
    account_id=ACCOUNT_ID,
)

# Assuming that collection `example-collection` exists and contains data

search_results = vantage_instance.semantic_search(
	text="example query",
  collection_id="example-collection",
  vantage_api_key="VANTAGE_API_KEY",
)

print(search_results)
./cli.py semantic-search --text "my query text" "example-collection" 

Embedding Search

The following example demonstrates how to perform a embedding search over the collection example-collection.

For more details on how it works, visit our Embedding Search documentation page.

from vantage_sdk import VantageClient

vantage_instance = VantageClient.using_vantage_api_key(
    vantage_api_key=VANTAGE_API_KEY,
    account_id=ACCOUNT_ID,
)

# Assuming that collection `example-collection` exists and contains data

search_results = vantage_instance.embedding_search(
	embedding=[0.1, 0.2, 0.3],
  collection_id="example-collection",
  vantage_api_key="VANTAGE_API_KEY",
)

print(search_results)
./cli.py embedding-search --embedding [-0.010061902925372124, -0.017514921724796295, .... ] "example-collection"

More-Like-This Search

The following example demonstrates how to perform a more-like-this search over the collection example-collection.

For more details on how it works, visit our More-Like-This Search documentation page.

from vantage_sdk import VantageClient

vantage_instance = VantageClient.using_vantage_api_key(
    vantage_api_key=VANTAGE_API_KEY,
    account_id=ACCOUNT_ID,
)

# Assuming that collection `example-collection` exists and contains data

search_results = vantage_instance.more_like_this_search(
	document_id="DOCUMENT_ID",
  collection_id="example-collection",
  vantage_api_key="VANTAGE_API_KEY",
)

print(search_results)
./cli.py more-like-this-search --document-id "document-123" "example-collection"

More-Like-These Search

The following example demonstrates how to perform a more-like-these search over the collection example-collection.

For more details on how it works, visit our More-Like-These Search documentation page.

To understand and create a list of these objects, the best option is to check all the details described here.

In the example below, these consists of four objects: the first two represent image embedding vectors, the third represents a document ID, and the fourth represents plain text. Vantage will be able to perform a search based on all of these objects and find a group of new objects that match the most.

from vantage_sdk import VantageClient

vantage_instance = VantageClient.using_vantage_api_key(
    vantage_api_key=VANTAGE_API_KEY,
    account_id=ACCOUNT_ID,
)

# Assuming that collection `example-collection` exists and contains data

these = [
  {
    "embedding": [ 0.2, 0.1, -0.1 ... ],  // Image 1
    "weight": 0.15 
  },
  {
    "embedding": [ 0.1, 0.11, -0.9 ... ], // Image 2
    "weight": 0.15 
  },
  {
    "query_document_id": "item-27",       // Item 27 in collection
    "weight": 0.2 
  },
  {
    "query_text": "soft chair",           // Search Bar Text 
    "weight": 0.5 
  }
]

search_results = vantage_instance.more_like_these_search(
	more_like_these=these,
  collection_id="example-collection",
  vantage_api_key="VANTAGE_API_KEY",
)

print(search_results)
./cli.py more-like-these-search --more-like-these-json '[{"embedding": [ 0.2, 0.1, -0.1 ... ], "weight": 0.15 },{"embedding": [ 0.1, 0.11, -0.9 ... ], "weight": 0.15 }]' "example-collection"