In modern development, application logic and data are deeply intertwined. We often find ourselves writing complex SQL queries, scattering them throughout our codebase to fetch the data we need. While this approach works, it creates a cascade of problems: it's brittle, insecure, and incredibly difficult to maintain or reuse. What if there was a better way? What if you could treat data retrieval not as a messy implementation detail, but as a clean, manageable piece of software itself?
Welcome to the world of Search as Software. With Searches.do, you can transform any complex data retrieval task—from a simple SQL query to a multi-step data aggregation process—into a secure, scalable, and reusable API endpoint. We call these endpoints Intelligent Search Agents.
This post will guide you through converting a common SQL query into your very first intelligent search agent, demonstrating how you can abstract away complexity and embrace a "Business-as-Code" methodology for data retrieval.
Imagine you're building an e-commerce platform. A common requirement is to display a customer's profile along with their most recent orders. In a traditional setup, you might write a SQL query directly in your backend service:
-- This query lives somewhere in your application code
SELECT
u.user_id,
u.first_name,
u.email,
u.signup_date,
o.order_id,
o.order_date,
o.total
FROM
users u
LEFT JOIN
orders o ON u.user_id = o.user_id
WHERE
u.email = ? -- Parameter from user input
ORDER BY
o.order_date DESC
LIMIT 5;
This query gets the job done, but it introduces several challenges:
Searches.do introduces a powerful abstraction layer. Instead of embedding SQL in your app, you encapsulate it within a named, version-controlled Search Agent.
This agent is a self-contained unit of data retrieval logic. It knows what data source to connect to, what parameters it accepts, and how to securely execute the query to fetch the required information. Your application no longer speaks SQL; it speaks the language of your business.
This shift offers immediate benefits:
Let's convert our previous SQL query into a powerful and reusable Search Agent.
Inside the Searches.do platform, you define a new agent. This process involves three key parts:
The agent definition encapsulates the how, freeing your application to focus on the what.
With the click of a button, you deploy your agent. Searches.do instantly makes it available as a secure API endpoint. It's now a live, callable "Service-as-Software" that's ready to be consumed.
Now, let's look at the "after" picture. Your application code is transformed from a messy block of SQL into a clean, declarative API call.
Using the searches.do client library, your code becomes beautifully simple:
import { createClient } from 'searches.do';
// Initialize the client with your API key
const searches = createClient(process.env.DO_API_KEY);
// Effortlessly run our newly defined search agent
async function findCustomer(email: string) {
const customerData = await searches.run('find-customer-with-recent-orders', {
email: email
});
console.log('Found customer and their orders:', customerData);
return customerData;
}
findCustomer('jane.doe@example.com');
The difference is night and day. The application code is readable, secure, and completely decoupled from the underlying data source. If you later decide to migrate from SQL to a NoSQL database or a microservice, you only need to update the agent's logic in Searches.do. Your application code does not change.
The concept of a "search" agent goes far beyond fetching single records. An agent can represent any data-oriented task:
By creating a library of these agents, you build a robust and scalable agentic workflow platform for your entire organization, promoting reuse and consistency across all your products and services.
Stop scattering queries and start building intelligent, reusable data retrieval agents. By treating your searches as first-class software components, you'll build more secure, maintainable, and scalable applications.
Ready to turn your complex queries into simple, powerful APIs? Visit Searches.do to get started and experience the future of intelligent data retrieval.