VecDB API
  • 🌱VecDB
  • 🌱Structure
  • 🌱Glossary
  • 🌱FAQ
  • πŸ’»API Reference
  • Get Started
    • πŸ’»Authentication
    • πŸ’»Build Your First Search
      • πŸ’»Creating your first dataset
      • πŸ’»Encoding + Inserting
      • πŸ’»Your First Text To Image Search!
  • for your understanding
    • 🌱Concepts about vectors
    • 🌱What is vector search?
    • 🌱Vectors for classification
    • 🌱Limitations of vectors
  • Guides
    • πŸ’»Combine keyword search with vector search
  • ADMIN
    • 🌱Project Overview
      • πŸ’»Project Creation
      • πŸ’»List All Datasets
      • Best Practice With Project Management
      • πŸ’»Copy dataset
      • πŸ’»Copy dataset from another project
      • πŸ’»Request an API key
      • πŸ’»Request a read-only API key
  • Services
    • πŸ”Search
      • Text Search
      • Vector Search
      • Hybrid Search
      • Traditional Search
    • πŸ”Predict
      • πŸ’»KNN regression from search results
      • πŸ’»KNN Regression
    • πŸ”Tag
      • πŸ’»Tagging
      • πŸ’»Diversity Tagging
    • πŸ”Cluster
      • Cluster A Dataset Field
  • DATASETS
    • 🌱Datasets Overview
      • 🌱Special Field Types
  • WORKFLOWS
    • 🌱Workflow Overview
Powered by GitBook
On this page

Was this helpful?

  1. Get Started
  2. Build Your First Search

Your First Text To Image Search!

Now that it is inserted, let's perform our first text to image search!

Now, let us perform our first text to image search!

So what do we need to do? On the previous page, we inserted our documents with vectors. Now, we want to search those same vectors using text.

import requests
def encode_text(text, project, api_key):
    return requests.post(
        url="https://api-dev-aueast.relevance.ai/v1/services/encoders/textimage",
        headers={"Authorization": project+ ":" + api_key},
        json={
            "text": text
        }
    ).json()["vector"]

Store your encoding like below:

vector = encode_text("frogs", project, api_key)

Now that you have the vector, you can perform your first search using the vector search endpoint.

We then run our vector search on our results!

dataset_id = "coco-dataset"
url = "https://api-dev-aueast.relevance.ai/v1/services/search/vector"
response = requests.post(
    url=url,
    headers={"Authorization": project + ":" + api_key},
    json={
        "dataset_id": dataset_id,
        "multivector_query": [{"vector": vector, "fields": ["image_vector_"]}]})
response.json()

Go ahead and try out more searches!

PreviousEncoding + InsertingNextConcepts about vectors

Last updated 3 years ago

Was this helpful?

πŸ’»
πŸ’»