Drupal AI Ecosystem Part 4: Drupal AI Search with PostgreSQL Vector Database
Search is one of the most important ways people find information online. Whether it’s looking for a product, a tutorial, or an answer to a question, users expect search to "just understand” what they mean. Traditional search engines, however, often rely on matching exact keywords. If you search for “create a chatbot”, but an article is titled “building conversational assistants”, you might never see it, even though it’s exactly what you need. That’s where Drupal AI Search changes the game.
Instead of focusing on keywords, Drupal AI Search focuses on meaning. Utilizing artificial intelligence and vector databases, Drupal AI Search recognizes the relationships between words and concepts. Drupal AI Search can connect a user’s question with the most relevant information, even if the wording is completely different.
In this article, we’ll explore how to build an AI-powered search for your Drupal website using PostgreSQL’s Vector Database. You’ll see how it works, how to set it up, and how it can transform your search experience, making it faster, smarter, and more human-like.
Before implementing Drupal AI Search, see how our team can guide you in building AI-powered, vector-based search experiences that elevate content discovery and engagement.
Now, let's understand Drupal AI Search and more!
Drupal AI Search: Your Adaptive Discovery Engine
Imagine if your website’s search bar could understand what people mean, not just what they type. That’s the idea behind Drupal AI Search.
Traditional search engines look for exact keyword matches. If you type “how to cook pasta”, they’ll only show pages that contain those same words. But what if the best article says “tips for making Italian noodles”? You might miss it completely.
Drupal AI Search works differently. It uses artificial intelligence to understand the meaning behind words. It turns both the content on your site and the user’s query into special numeric representations called embeddings. These embeddings capture the relationships between words, ideas, and context, almost like how our brains connect similar concepts.
For example: “How to cook pasta” and “Boiling spaghetti the right way” - even though the wording is different, Drupal AI Search knows they mean nearly the same thing. So, it can show both results when someone searches.
Why Use PostgreSQL Vector Database?
There are several specialized databases built for Drupal AI search, like Pinecone, Milvus, or Weaviate. These tools are powerful and purpose-built for vector search, but they often require setting up a separate service, managing new infrastructure, and handling extra costs.
With PostgreSQL’s pgvector extension, you can get the same vector search capabilities without adding another database system. It allows you to store and search embeddings directly in your existing PostgreSQL database, the same one already powering your Drupal site.
This approach has a few big advantages:
- No extra infrastructure is required: You use the database you already have.
- Cost-effective: No need to pay for or maintain a third-party vector service like Pinecone.
- Secure and simple: Your data stays in your own environment, reducing complexity and integration risk.
- Performance-ready: PostgreSQL with pgvector; can handle semantic search efficiently for many Drupal use cases.
In short, by using PostgreSQL’s vector database, you can bring AI-powered semantic search into Drupal quickly and affordably, leveraging the infrastructure you already trust.
How Drupal AI Search Works
Drupal AI Search works by converting both your website’s content and user queries into a format that computers can understand: numbers. These numbers, called embeddings, represent the meaning of the text instead of just the words.
Here’s what happens step by step:
- Content Embedding: When new content is added to your Drupal site, an AI model (like OpenAI or Hugging Face) converts the text into an embedding, a list of numbers that captures its meaning. This embedding is then stored in your PostgreSQL database using the pgvector extension.
- Query Embedding: When someone searches, their query is also turned into an embedding.
- Similarity Search: PostgreSQL compares the query’s embedding with the stored content embeddings to find the most similar ones. This comparison uses mathematical distance (like cosine similarity) to measure how close the meanings are.
- Results Ranking: The closest matches are shown first, giving the user the most relevant results, even if the exact words don’t match.
So when a user searches for “create a chatbot”, Drupal AI Search can also show results like “building conversational assistants”. It understands meaning, not just text.
Drupal AI Search Setup
Drupal Modules
- Search API: Core search framework for Drupal that allows you to index and query content.
- Key: Securely stores API keys for your AI services.
- AI Core: Provides the base architecture for AI integrations in Drupal.
- AI Provider: Connects Drupal to external AI models (e.g., OpenAI, Gemini).
- Postgres VDB Provider: Enables PostgreSQL Vector Database (pgvector) support for storing and querying embeddings.
- AI Chatbot (AI Core): Adds a conversational interface for users to interact with site content.
- AI Assistant (AI Core): Integrates intelligent assistants that can understand context and perform actions accordingly.
- AI API Explorer (AI Core): Helps test and manage API connections directly within Drupal.
- AI Agents: Automates advanced AI-driven tasks and workflows.
Database
- PostgreSQL 15+: Your main database for Drupal.
- PostgreSQL Vector Extension (pgvector): Adds vector data types and similarity search functions.
Installation
- Configure Lando Services
name: drupal-11 recipe: drupal11 config: webroot: web php: "8.4" composer_version: "2-latest" xdebug: false via: nginx services: appserver: build_as_root: - apt-get update && apt-get install -y libpq-dev && docker-php-ext-install pgsql pg: type: postgres:17 portforward: true creds: database: database user: postgres password: NO PASSWORD build_as_root: - apt-get update && apt-get install -y tooling: psql: service: pg cmd: psql -U postgres database - Enable the Vector Extension
- Log in to your PostgreSQL service:
- Then enable the pgvector extension:
CREATE EXTENSION vector;
- Verify the Installation
- By Command Line
/dx
- pgAdmin

- By Command Line
- Configure Vector DB
- Postgres configuration
- Run lando info --service pg to get the configuration

- Configure Postgres DB
Navigate To: admin/config/ai/vdb_providers/postgresSettings Description HOST Use the internal host provided by Lando (usually database or pg). PORT Use the internal port number from Lando (default 5432). USERNAME postgres (or the username defined in .lando.yml). DATABASE Use the database name defined in .lando.yml (e.g., database).

- Run lando info --service pg to get the configuration
- Postgres configuration
- Configure Search API
- Navigate to Search API page: admin/config/search/search-api
- Add Server
- Select backend: Drupal AI Search
- Embeddings Engine
- Vector Database: Postgres vector DB
- Vector Database Configuration
- Database Name: database(Can change based on configuration)
- Collection: Any valid collection (If the collection doesn’t exist, it creates a new collection)
- Similarity Metric: Cosine similarity measures how close two pieces of text are in meaning by calculating the angle between their vector representations; the smaller the angle, the more similar they are.
- Add Index
- Database source: Content (Can be anything)
- Server: Previously created server Assistant


- Add Field: Navigate to the Fields Tab
- Click on Add Fields to add a new field
- Select: Body or Rendered HTML output:
- Type: Full text
- Index option: Main Content
- Title:
- Type: String
- Index option: Contextual Content

- Select: Body or Rendered HTML output:
- Index the content
- Navigate to the view page of the index to index the content.

- Verify collection in Postgres.

- Navigate to the view page of the index to index the content.
- Test Vector Database
- Navigate to admin/config/ai/explorers/vector_db_generator
- Add Prompt and run db query.

- Response:

AI Assistant: Your Conversational Search Companion
An AI Assistant is an intelligent, conversational interface that allows users to interact with your website naturally, just like talking to a smart helper. Instead of relying on keyword matches, it understands context, retrieves relevant information, and delivers human-like responses based on your site’s content.
Think of it as a bridge between your content and your users, one that understands intent and meaning, not just words.
- Understand context: It doesn't just match keywords but comprehends what users are actually asking for
- Retrieve relevant information: Using RAG (Retrieval-Augmented Generation), it searches through your indexed content to find the most relevant answers
- Provide conversational responses: It responds in natural language, making information more accessible and user-friendly
- Learn from your content: The assistant uses your website's actual content as its knowledge base, ensuring accurate and up-to-date responses
Key Components Of An AI Assistant
RAG (Retrieval-Augmented Generation): RAG is the backbone of intelligent search. Instead of relying solely on pre-trained knowledge, RAG allows the AI to:
- Search your vector database for relevant content
- Use that content as context to generate accurate, site-specific answers
- Provide responses grounded in your actual documentation
Configuration Parameters:
- RAG Threshold: Controls how closely results must match the query.
- Lower = broader results
- Higher = stricter, more relevant matches
- Max Results: Limits how many search results the assistant considers when formulating an answer
- AI Provider: The underlying language model (OpenAI, Gemini, etc.) that powers the conversational interface
- Prompt Instructions: You can guide the assistant’s tone or purpose, such as “Answer in short, clear sentences” or “Be detailed and include examples.”
Setup Steps
- Navigate to AI Assistant Page: admin/config/ai/ai-assistant;

- Click on Add AI assitant.
- Add Basic Configuration:
- Label
- Description
- Instruction
- Configure Rag
- Enable Rag
- Select RAD Database
- Rag threshold
- Max Results
- Select AI Provider


- Add Basic Configuration:
AI Agent: Your Intelligent Action Taker
While an assistant focuses on answering user questions, an AI Agent can plan, reason, and execute complex multi-step tasks using Drupal’s AI ecosystem, all powered by the AI Core, AI Provider, and Postgres Vector Database (VDB) modules.
Think of an agent as an intelligent Drupal worker that can analyze content, retrieve information, and perform actions automatically, not just respond to queries.
An AI Agent can:
- Make decisions autonomously: Break down complex user requests (like “summarize all recent AI blog posts”) into smaller tasks and execute them step-by-step.
- Use multiple tools: Integrate with the **RAG/Vector Search Tool**, APIs, and other AI modules to accomplish its goals.
- Handle multi-step workflows: Perform sequences such as retrieving related nodes, summarizing data, and formatting the output.
- Adapt dynamically: Adjust its approach based on context, user input, or intermediate results.
AI Agent vs AI Assistant: Key Differences
| Features | AI Assistant | AI Agent |
|---|---|---|
| Autonomy | Responds to user search queries and provides contextual answers from the vector database | Can plan, reason, and execute multi-step actions using Drupal AI Search results automatically |
| Complexity | Handles simple Q&A | Manages complex workflows and decision-making |
| Tool Usage | Primarily uses the RAG/Vector Search Tool to retrieve and display relevant results | Can use multiple tools and orchestrate them |
| Behavior | Reactive (waits for user input) | Proactive (can initiate actions based on goals) |
| Use Cases | Semantic search responses, knowledge-base Q&A, FAQ-style interactions | Automated content summarization, insight extraction, workflow orchestration, or generating reports from Drupal AI Search results |
Swarm Orchestration
Swarm orchestration enables multiple AI agents to collaborate, coordinating their efforts to solve increasingly complex problems. This is useful when:
- Different agents have specialized knowledge or tools
- Tasks require collaboration between multiple AI systems
- You need to distribute the workload across different AI capabilities
Agent Instructions Structure
When configuring an agent, divide instructions into three clear sections:
- Role: Define what the agent is and its primary purpose. Example: "You are a technical documentation assistant specialized in Drupal development."
- Behavior: Specify how the agent should act, communicate, and make decisions. Example: "Always provide code examples when explaining concepts. Be concise but thorough. If information is incomplete, say so rather than guessing."
- RAG Behavior: Define how the agent should use the vector search tool and retrieve content. Example: "When searching for information, use the RAG tool first. If results are insufficient, acknowledge the limitation. Always cite sources from the knowledge base when providing answers."
RAG/Vector Search Tool
The RAG/Vector Search Tool allows agents to:
- Query the vector database for relevant content
- Retrieve semantically similar information based on context
- Ground their responses in actual site content rather than general knowledge
- Provide more accurate, domain-specific answers
Configuration Steps
- Navigate to the AI Agent page: admin/config/ai/agents
- Configure Agent:
- Add Label and Description
- Enable "Swarm orchestration agent" (if you need multi-agent coordination)
- Provide detailed instructions divided into three sections:
- Role: Define the agent's identity and purpose
- Behavior: Specify how it should act and communicate
- RAG Behavior: Explain how to use vector search and handle retrieved content
- Add the Tool "RAG/Vector Search Tool" to enable semantic search capabilities



Testing Your Agent
Test RAG AI agent by navigating to: admin/config/ai/explorers/tools_explorer;

Use the tools explorer to verify that your agent:
- Correctly interprets user queries
- Retrieves relevant content from the vector database
- Provides accurate and contextual responses
- Uses the RAG tool appropriately
Deep Chat
- Add Deep Chat block.
- Select an AI assistant.

- Select an AI assistant.
- Test Deep Chat With RAG

-

Boost Traditional Search With AI- Navigate to index preprocess page: admin/config/search/search-api/index/{index}/processors
- Enable Boost Database by Drupal AI Search


Also Check Out
- Drupal AI Ecosystem Part 1: Setup and AI CKEditor Configuration
- Drupal AI Ecosystem Part 2: AI Logging, Observability, & API Explorer
- Drupal AI Ecosystem Part 3: Drupal AI Translate Module
- Transform Your Website with Drupal AI Module in 2025
Key Takeaways
- Drupal AI Search moves from keyword-focused search to understanding meaning, utilizing AI embeddings and vector databases.
- Using PostgreSQL with pgvector makes AI search affordable and simple to implement, enabling teams to utilize their current Drupal database for semantic search.
- Drupal AI Search utilizes embeddings, similarity search, and result ranking to provide highly relevant and context-aware search experiences.
- Drupal's AI ecosystem extends beyond search; it includes AI Assistants for conversational, RAG-powered Q&A and AI Agents for independent, multi-step task execution.
- A complete setup guide helps developers implement semantic search, covering everything from configuring pgvector to deploying AI Assistants, Agents, and Deep Chat.
Subscribe
Related Blogs
Drupal AI Ecosystem Part 3: Drupal AI Translate Module
In today’s fast-paced digital landscape, delivering content that resonates across languages is no longer optional; it’s…
Drupal AI Ecosystem Part 2: AI Logging, Observability, & API Explorer
In the first part of our series, we explored the foundational architecture, setting up the Drupal AI Ecosystem and AI…
DrupalCon Vienna Key Takeaways: Transforming Drupal with AI
Dries delivered his 43rd keynote at DrupalCon Vienna! “AI is the storm… but instead of turning away, we need to embrace AI…