Semantic search for Mattermost Agents with pgvector

Permission-aware semantic search lets Mattermost agents find relevant channel history while keeping vectors in your own PostgreSQL database. This page covers the prerequisites, embedding settings and controls to confirm before you enable it.

On this page

What semantic search over Mattermost channel history needs

Teams want their agents to answer questions from years of channel history, but two conditions have to hold at the same time: each user should only get answers drawn from channels they are allowed to read, and the messages, embeddings and any model calls should stay inside the organization's boundary. Semantic search is the mechanism that makes this practical. Instead of matching keywords, the server converts message text into vectors and retrieves the messages whose meaning is closest to a question, then passes the matching content to the agent. Teams usually need this when keyword search misses context spread across many conversations, such as incident threads, design decisions or customer escalations that were phrased differently over time. The vectors are stored in PostgreSQL through the pgvector extension, so the same database governance you already run for Mattermost applies to them.

The retrieval layer is where permission behavior matters most. Before adopting it, confirm against the Mattermost Agents documentation for your exact server version how retrieval results are filtered by channel membership, whether private channels and archived channels are covered, and what happens when a user's access changes after messages were indexed. Also confirm which pgvector version your PostgreSQL major version supports, which embedding settings are exposed in the plugin configuration, and whether embeddings are generated by a provider you host or by an external service. Each of those answers changes where data travels, so write them down as acceptance criteria before any indexing starts.

Treat this section as the decision point, not the configuration guide. Database prerequisites, the default bot, LLM service selection and hostname allowlists are covered in the sibling page on setting up the Mattermost Agents plugin, and self-hosted model backends and air-gapped operation are covered in the sovereign and air-gapped AI page. Read those first, then return here to plan the vector store, the embedding path and the permission tests you will run against a staging instance. Ask DeployOpen or your own platform team to document the exact plugin version, the PostgreSQL version and the embedding endpoint in the same change record so that an upgrade later does not silently move data outside your boundary.

Which database placement fits your data controls

This table compares four places to host the PostgreSQL database that stores Mattermost Agents vectors, across data boundary, operational load, backup scope, failover and administration. Read each row against your own data classification and staffing. The main takeaway is that a read replica adds read capacity but does not take writes, so embedding writes always land on the primary.

PlacementData boundary and backup scopeFailover and operationsWho administers it
Single PostgreSQL primary shared with MattermostVectors sit in the same database as channel data, so they share its boundary and its backup set. Backups must cover the pgvector tables with the rest of the database.No standby by default. An outage stops Mattermost and agent search together. Recovery depends on tested restores, not on a second node.Mattermost platform team, with the database owner reviewing schema and extension changes.
Primary with read replicasReplicas hold copies of the same data inside your boundary. Each replica must be covered by the same encryption, access and retention controls as the primary.Replicas serve read-only queries, and writes still go to the primary. Promoting a replica needs an external failover tool, because PostgreSQL does not detect failure on its own.Database team, which must also watch replication lag and replica placement.
Dedicated PostgreSQL instance for vectorsVector data is isolated from Mattermost's core tables, which can narrow who can read embeddings. Mattermost still needs a path to the index, and the instance is a second backup scope to manage.Adds a component that can fail independently. Agent search can degrade while chat keeps working, so monitor both systems and document the dependency.Shared between the database team and the Mattermost team, with clear ownership of the extension and index.
Managed PostgreSQL in your own cloud accountData stays in an account you control, but the provider operates the service layer. Confirm where backups, snapshots and logs are stored and who holds the keys.Provider-managed failover and backups may reduce manual work. Confirm the pgvector version offered, the extension's availability and the recovery point you can actually restore to.Split between your cloud team, which controls the account, and the provider, which runs the instance. Confirm the responsibility split in writing.

How a channel message becomes a permission-checked answer

The flow starts when a message is posted or imported into a Mattermost channel. The Mattermost server hands the text to an embedding endpoint, then stores the returned vector in PostgreSQL alongside the message reference. When a user asks the agent a question, the query is embedded the same way, a similarity search runs in pgvector, and results are filtered against that user's channel membership before anything reaches the LLM provider. Check that each trust boundary is where your security review expects it, especially whether the embedding endpoint and LLM provider sit inside your network.

Message flow from embedding and pgvector storage through a membership-filtered query to the agent reply.

Preparing PostgreSQL for vector search

This sequence takes a Mattermost database from version checks through a verified pgvector setup, so the Agents plugin can store and query embeddings inside your own PostgreSQL instance. Each step ends with a check that confirms the database is ready before the next one starts.

  1. Confirm the Mattermost server and PostgreSQL versions

    Start by recording the Mattermost server version you run and checking that its documented PostgreSQL requirements match the database you plan to use. Mattermost publishes a new server binary on the 16th of each month, and Extended Support Releases such as v11.7 (support ending 2027-05-15) are a common choice for organizations that want fewer upgrades. Mattermost v10.11 has already reached end of life, so confirm your release is still supported before adding new features. Done means you have a written version pair for the server and database, reviewed by the platform owner.

  2. Choose a supported PostgreSQL major version

    Select a PostgreSQL major version that is still in support for the whole life of the deployment. PostgreSQL 14 is supported until November 12, 2026, PostgreSQL 15 until November 11, 2027, and PostgreSQL 18 until November 14, 2030, so a version that expires soon will force an upgrade shortly after go-live. Ask your DBA which major version your managed or self-hosted service offers, since not every provider ships every release. Done means the chosen version and its end-of-support date are recorded in the change ticket.

  3. Confirm a pgvector build exists for that version

    Check that a pgvector extension package is available for the exact PostgreSQL major version you chose, on the operating system or managed service image you run. Install it on a non-production instance first, so a missing package or mismatched build is found before the production change window. Confirm the package version with your database provider or distribution, because build availability varies by platform and this guide does not assume any particular release. Done means the extension installs cleanly on the test instance and the installed version is recorded.

  4. Create the extension in the Mattermost database

    A database administrator connects to the Mattermost database and runs CREATE EXTENSION for vector, using a role that has the privileges your PostgreSQL service requires for extensions. Keep the Mattermost application role separate from the administrative role, and grant only the access the Agents plugin needs. Run the same command against a restored copy first so the production change is repeatable. Done means the extension appears in the extension catalog of the Mattermost database and the application role can see it.

  5. Set SCRAM password authentication

    Configure the PostgreSQL server so password logins for the Mattermost role use SCRAM-SHA-256, and confirm that the password_encryption setting and the pg_hba.conf entries for the Mattermost role match that method. PostgreSQL 18 deprecates MD5 password authentication in favor of SCRAM, so this step also prepares the database for later upgrades. Restrict the Mattermost role to the database and client addresses it needs. Done means a test login from the Mattermost server succeeds and a query against the password hash settings for the role shows SCRAM.

  6. Check connection pooling with PgBouncer

    If you place PgBouncer between Mattermost and PostgreSQL, test that the pooling mode and settings keep the Agents workload working, including the extension, prepared statements and long-running embedding queries. Pooling modes can affect session state, so confirm with the Mattermost deployment team which mode is supported for your configuration before choosing one. Run a sustained test that mirrors your expected search traffic and watch for errors. Done means the pooler passes the test with no unexpected session errors, and the pooler configuration is saved in version control.

  7. Verify with a test query and a backup restore

    Run a small vector similarity query against a test table in the Mattermost database to confirm that the extension computes distances and returns rows as expected, then remove the test table. Next, take a backup of the database and restore it into a separate instance, confirm the vector extension is present there, and rerun the query. Record the restore time and any errors in the runbook. Done means the query returns the expected result on both instances and the restore has been tested, not just the backup job.

Keeping embeddings inside your own database

Storing vectors in your own PostgreSQL is only half of the boundary. The embedding model turns channel text into vectors, and that call can leave your network if the model is hosted by an external API. Every message or query sent for embedding is data in transit, so this step needs the same scrutiny as the database. Start by naming the embedding provider and where its endpoint runs. If you host the model in your own infrastructure, the text stays inside your network. If the provider is an external API, obtain its written data handling terms covering retention, logging, training use and the region that processes requests, and confirm that your contract covers that processing.

The hostname allowlist and outbound proxy settings from the plugin setup decide whether the Agents plugin can reach that endpoint at all. Add only the embedding endpoint's hostname to the allowlist, and route it through your approved egress proxy if your network requires one. Do not treat the allowlist as proof of containment, because a permitted hostname may front a shared cloud service and a proxy may log request bodies. Test from the Mattermost server itself, since the plugin's outbound traffic originates there. Confirm that a blocked hostname fails closed, so the feature stops and does not fall back to another provider.

Before sign-off, get answers in writing for the questions your security team will ask. From the embedding provider, confirm where requests are processed, whether inputs and outputs are stored or logged and for how long, whether your data is used to train models, and which independent assessments the provider holds. From your own environment, confirm that the pgvector extension and the embedding tables live in a database you control, that backups and replicas of that database stay within the same boundary, and that egress logs during a test run show calls only to approved hostnames. Keep these answers with the configuration record, because provider terms change over time and the review should be repeated when they do.

Permission checks search results must respect

Semantic search only helps if it never shows a user, or a bot, content they could not read in Mattermost. The cards below cover the failure points we see most often when channel history is copied into a vector store: access changes, deletions, retention holds and bot reach. Each card names the control to design and the test to run before go-live.

Private and archived channel leakage

Vector rows copied from channel history can be returned to users who are not members of a private channel, or who should no longer see an archived one. Design the query so every search filters on the requesting user's current channel membership, checked at query time rather than at indexing time. Test with a non-member account, a removed member and an archived channel, and confirm none of their content appears in answers or citations.

Vectors that outlive deleted messages

When a message is deleted or edited, its embedding in pgvector stays behind unless your sync job removes or replaces it. Stale vectors can then surface text the author has withdrawn. Design a delete and update path driven by Mattermost events, and confirm with your own environment which events your integration receives. Test by deleting and editing a message, then searching for its original wording.

Retention and legal hold gaps

Retention policies and legal holds apply to messages in Mattermost, but they do not automatically reach a separate vector table. A vector copy can outlast the message it came from, or be purged while a hold still requires it. Map each retention rule to a deletion job for the embedding table, and confirm how holds should interact with that job before you enable indexing. Test by applying a short retention rule to a test channel and checking that its vectors are removed.

Bot-readable content exposed to users

An agent may be allowed to read channels that a given user cannot. If the bot retrieves from its own scope and returns the results to the requester, it can reveal content the requester could never open directly. Design retrieval so the result set is the intersection of the bot's permissions and the requester's permissions. Test with a user who can see less than the bot, and confirm the answer and its source citations contain nothing outside the user's view.

Backups and replicas holding stale copies

Vector data lives in PostgreSQL, so it is copied into backups, point-in-time recovery archives and read replicas. Restoring an old backup can bring back embeddings for messages that were later deleted or placed under a hold. Document how long backups are kept, whether restores re-run the deletion job, and who approves a restore. Test by restoring a backup into a separate environment and checking for content that should have been removed.

Archiving and recovery docs

Access grants that drift over time

Membership changes, guest accounts and deactivated users change what should be searchable, but a cached permission list or an unreviewed service account can keep old access alive. Design the search service to read permissions live from Mattermost, use a dedicated database role with the least privilege it needs, and review that role's grants on a set schedule. Test by deactivating a user and removing a channel membership, then confirming both lose search results immediately.

Sizing the vector store by deployment environment

On a single server, the Mattermost application and the PostgreSQL database share one failure domain, so the vector store is only as available as that host. Storing embeddings in the same PostgreSQL instance as Mattermost keeps the architecture simple, but the pgvector index competes with message and file metadata for memory, disk and I/O. Plan the host around the size of your channel history, not only the number of users.

  • Storage placement: Keep the PostgreSQL data directory on a volume with enough headroom for the vector tables and their indexes, and confirm how the index grows as history accumulates.
  • Replication: There is no standby, so a host failure stops both chat and search until the database is restored.
  • Failover: PostgreSQL does not detect a primary failure or fail over by itself, and a single server has no standby to promote, so recovery is a restore from backup.
  • Backups: Schedule base backups with WAL archiving so you can restore to a point in time, and test the restore, including the vector tables.
  • Embedding model location: Confirm whether the embedding model is a hosted API or a model you run locally, because an external call sends channel content outside the server.

Before you commit to this design, ask the vendor and your DBA to confirm index type, memory settings and expected growth for your history size.

Operating the vector store after go-live

Once semantic search is live, the vectors are ordinary data in your PostgreSQL database, so they need the same recovery discipline as messages. Confirm that continuous archiving and point-in-time recovery are running for the database that holds the embedding tables and the pgvector extension, and test a restore to a point in time before you rely on it. The PostgreSQL documentation on continuous archiving and point-in-time recovery describes the mechanism. Restore tests should also confirm that the vector indexes come back usable and that the Mattermost search results match what they returned before the restore.

Vectors also depend on two things that change over time: the embedding model and the extension version. If you change the embedding model, every stored vector must be regenerated, because vectors from different models are not comparable. Treat each model change, each pgvector upgrade and each PostgreSQL upgrade as a planned change with its own test cycle: re-embed a copy, compare retrieval results for a fixed set of test queries against your permission rules, measure query latency, then cut over. Confirm with your Mattermost and pgvector versions which combinations you have tested, and keep the previous embedding table until the new one is verified.

PostgreSQL minor releases replace executables and restart the server, and they do not change the storage format, so they fit a planned maintenance window. Major upgrades need a choice between pg_upgrade, dump and restore, or logical replication, which the PostgreSQL upgrading documentation compares. Check that your pgvector build supports the target major version before you start, and rerun your retrieval tests afterward. Finally, monitor table and index growth and query latency for the vector tables over time, since both drive storage sizing, index maintenance and the cost of a future re-embedding run.

Limits to confirm in your environment

Semantic search for Mattermost Agents depends on four moving parts: the Mattermost release and plan level, the PostgreSQL major version, the pgvector extension and the embedding settings. Each card below is a point where a version or product boundary can change what you build, so confirm it before you size the database or schedule the work. DeployOpen will check each item against the documentation for your target version.

pgvector and PostgreSQL compatibility

The pgvector extension is built against specific PostgreSQL major versions, and your database has to run one of the versions still in support. Mattermost's own database requirements also set a floor. Confirm that the pgvector release you plan to install supports your PostgreSQL major version, and check which PostgreSQL major version is on your upgrade path. Confirm the pairing before you install anything in production.

Oldest supported major
14
PostgreSQL versions

Release and plan level

Semantic search is not a feature you can assume from the server version alone. Check which Mattermost Agents plugin release includes this search, and whether your Mattermost plan level includes the Agents capability you need. Pricing and plan inclusions are set by Mattermost, so request the current plan matrix from Mattermost sales in writing rather than relying on an older comparison.

Monthly release day
16th
Mattermost releases

Embedding options in your version

The embedding model and the provider that serves it determine where message text is sent and how vectors are produced. Not every server version offers the same embedding choices, and the options may differ between a hosted provider and a self-hosted model. List the embedding options your target version exposes, then confirm whether each one keeps text and vectors inside your network or sends them to an outside service.

Coverage of threads, files and archives

Channel messages are the obvious source for search, but threads, attached files and archived channels may be indexed differently or excluded. Each gap changes what an agent can answer and what a data owner expects to be searchable. Ask Mattermost to state, for your version, whether replies, file contents and archived channels are included, and test each category with a sample channel before you accept the result.

Reindexing on large histories

Building vectors for years of channel history is a long, resource-heavy job that competes with normal traffic. You need to know whether reindexing can run in the background, whether it can resume after a failure, and whether a model change forces a full rebuild. Ask for the documented reindex procedure and test it on a copy of a large history so you can size storage, database load and the window for the job.

Questions buyers ask before enabling semantic search

What drives the cost and effort of semantic search for Mattermost Agents?

Four components drive most of the cost: database administration, embedding infrastructure, permission testing and ongoing re-embedding. Database administration covers installing pgvector on a supported PostgreSQL version, sizing storage and index memory, and backing up vector data with everything else. Embedding infrastructure is the model that turns messages into vectors, either a hosted service or a model you run yourself, and each option carries its own compute or subscription cost. Permission testing is largely one-time but takes care, because results must respect channel membership. Re-embedding recurs whenever you change the embedding model, its dimensions or the chunking method. Ask for each component to be priced separately in any quote.

How long does a pgvector search setup take to deliver?

No duration can be fixed until the scope is known, because the work depends on the size of your channel history and your environment. A small history on a current PostgreSQL version is a very different job from a multi-year archive that needs a staged backfill, throttling and a phased rollout. Other drivers include the number of channels, how complex their permission model is, the state of your database estate and whether your embedding model is hosted or self-run. Ask the partner to break the written scope into phases such as prerequisites, a pilot channel set, backfill, permission tests and cutover, and to state the history size and environment behind each duration.

What must our team provide before the work starts?

Your team needs to provide four things. First, database access, either an account that can create extensions or a database administrator who will install pgvector. Second, a PostgreSQL version decision. Support for version 14 ends November 12, 2026, version 15 on November 11, 2027, version 16 on November 9, 2028, version 17 on November 8, 2029 and version 18 on November 14, 2030, so pick a version that stays supported for your planned operating life. Third, a data classification and retention policy, which decides what enters the index and how long vectors are kept. Fourth, test accounts with different channel memberships so permission filtering can be checked directly.

Can our internal team implement semantic search without an outside partner?

Yes, if you have a PostgreSQL administrator, someone who operates Mattermost, and an engineer comfortable with embedding pipelines and access testing. The installation is usually the smaller part. The harder work is proving that search results never cross channel boundaries, running re-embedding safely and keeping the setup working through Mattermost monthly releases and PostgreSQL minor releases. If you add read replicas, note that PostgreSQL does not detect a primary failure or promote a standby by itself, so your team would own the failover tooling. Compare your staff's time with the scope list before deciding.

Which Mattermost plan do we need before enabling AI features?

Mattermost sells Professional, Enterprise and Enterprise Advanced plans as prepaid annual subscriptions based on seat licenses, and its pricing page lists no public prices, so you must contact sales for a quote. According to that page, SSO and AD/LDAP user sync are included from Professional, high availability clustering and FIPS 140-3 compliance from Enterprise, and air-gapped deployment from Enterprise Advanced. The pricing page does not settle whether the Agents plugin or vector search is included in each plan, so confirm this in writing with Mattermost before you size the project.

What should a fixed-scope quote for this work list?

A useful quote lists the following items:

  • An inventory of your Mattermost server, PostgreSQL version and hosting environment
  • The pgvector installation and PostgreSQL version plan
  • The embedding model, where it runs and what text it receives
  • The data scope, including channels, date range and exclusions
  • A permission test plan using named test accounts
  • A re-embedding and model change procedure
  • Backup and restore steps for vector data
  • Acceptance criteria, deliverables, assumptions and exclusions
  • Phases with the timeline and the assumptions behind it

DeployOpen agrees the scope, deliverables and timelines in writing before work starts, so ask for these items in the same form from any provider.

How do we keep embeddings inside our own database and boundary?

Store embeddings in the PostgreSQL instance you operate, inside the same boundary as your Mattermost data, so backups, access control and retention follow controls you already run. Then confirm where the embedding model runs. A hosted embedding API receives channel text, so it sits outside your boundary unless you have approved that flow. Check the authentication method for database connections as well. PostgreSQL documents password, certificate, LDAP, OAuth and other methods, and PostgreSQL 18 deprecated MD5 password authentication in favor of SCRAM. Your security team should review these choices against your policy before go-live.

What ongoing work follows go-live for semantic search?

Several recurring tasks follow go-live. PostgreSQL publishes minor releases at least once every three months, and applying one means replacing executables and restarting, since minor releases do not change the storage format. Major upgrades use pg_upgrade, a dump and restore, or logical replication, and logical replication allows a major upgrade with only several seconds of downtime. Mattermost releases server versions in binary form on the 16th of each month, and each upgrade can affect the plugin and its database needs. Re-embedding runs whenever the model or chunking changes, and permission tests should repeat after each upgrade.

How DeployOpen works on this

DeployOpen plans and delivers semantic search for Mattermost Agents with pgvector inside infrastructure you control, starting from a written scope. The work covers the PostgreSQL database, the pgvector extension, embedding settings and access checks, so your team can review how channel history is indexed and retrieved.

How we scope

  • Confirm your Mattermost server version, plan level and PostgreSQL major version before any design work starts.
  • Agree which channels, teams and history ranges the agents may index, and who approves that boundary.
  • Document where embeddings are generated, stored and backed up, so the written scope names every system that holds vector data.

How we build

  • Prepare the PostgreSQL server with the pgvector extension and confirm it is available in your target environment.
  • Configure embedding settings and the Agents plugin so vectors stay in your own database, with the setup recorded as code or config.
  • Test that search results respect each user's channel permissions, using accounts that hold different memberships.

How we hand over

  • Deliver a configuration record covering database settings, embedding options, plugin settings and the permission test results.
  • Provide a runbook for index rebuilds, database backups and the steps to rotate or disable the search feature.
  • Walk your database, security and platform teams through the design so they can review it against your own controls.

How we support

  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
  • Plan PostgreSQL minor updates and planned major upgrades with the Mattermost release schedule in view.
  • Ongoing support, upgrades and continuous testing are available as a retainer after handover.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.