Search by Image with AI-Native Intelligence, Now in Public Beta

September 27, 2024
Team Objective

We’re sweating out the last few days of summer here at Objective HQ with another feature launch that we think will be worth a thousand words for some of you — or at least a thousand lines of code. This morning, we’re launching Image Search into Public Beta! Now, in addition to using text from your users as the input to a search query, you can provide an image as the input instead and get the same high-relevance results you expect from your Objective Indexes.

If you already have an Objective account, check out the docs! If you don’t have an account yet, there’s never been a better day to go grab one!

Making Image Search as Easy as Text Search

If you’ve ever built an app that uses standard text queries, then good news - you’re already an expert at Image Search (and you didn’t even know it!). Image Search is available on all Image & Multimodal search index types.

A standard GET query for a text search input will look something like this:


curl --request GET \
  --url 'https://api.objective.inc/v1/indexes/{YOUR_INDEX_ID}/search?query=green&20coat&20with&20big&20buttons' \
  --header 'Authorization: Bearer YOUR_API_KEY'

But the same text search query can also be run as a POST:


curl --request POST \
  --url 'https://api.objective.inc/v1/indexes/{YOUR_INDEX_ID}/search' \
  --header 'Authorization: Bearer YOUR_API_KEY'
  --header 'Content-Type: application/json' \
  --data '{"query_text": "green coat with big buttons"}'

And we can also use that POST version of search query request with an image input. It’s as simple as swapping the query_text body parameter with query_image, and passing in your base64-encoded image:


curl --request POST \
  --url https://api.objective.inc/v1/indexes/idx_123/search \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
  "query_image": {
    "type": "base64",
    "media_type": "image/jpeg",
    "data": "BASE64_STRING_ENCODING"
  }
}'

Using Image Search for more than just “search by image”

You’re probably already imagining some of the possibilities for what you can build with this new functionality (we know the feeling!). You can build lots of flavors of “reverse image search”, where you want to find images that are visually similar to other images.

Let’s say you’re building a recipe site. You want to let a user take a photo of the seasonal herbed potatoes they’re enjoying and search your database for recipes that might be a match:

And the Objects you’ve upserted to Objective all have a cover photo, like these:

And each of your Objects might be structured like this:


{
	"recipe_name": "Summer Herb Potato Salad",
	"recipe_photo": "https://...seasonal_potatoes.jpg",
	"prep_time": "50min",
	"servings": 8,
	"recipe_content": ...
}

Image Search is enabled on both Image and Multimodal Indexes - for a recipe app like you’re building, we’ll just use a simple Image Index:


curl --request POST \
  --url https://api.objective.inc/v1/indexes \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
  "configuration": {
    "index_type": {
      "name": "image"
    },
    "fields": {
      "crawlable": {
        "allow": ["recipe_photo"]
      }
    }
  }
}'

Getting results that look like your user’s photo is as simple as using that photo as the input to the search, like we saw above:


curl --request POST \
  --url https://api.objective.inc/v1/indexes/{YOUR_INDEX_ID}/search \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
  "query_image": {
    "type": "base64",
    "media_type": "image/jpeg",
    "data": "BASE64_STRING_ENCODING"
  }
}'

And just like that, you have one of the smartest food searching apps on the planet! We think the possibilities are just about endless for how you can combine Image Search with the other parts of the Objective platform to find creative new ways to make search a part of every user experience.

We can’t wait to see what you build!

Subscribe to our Newsletter!

Get the latest news and updates directly to your inbox.
Thank you! We'll get back to you as soon as possible.
Uh-oh... something went wrong. Please try again later.

We recommend you to read