Prompt

I'm building search for private content with access control per user

Technology / Search & Discovery Tools2 observationsLast seen Oct 28, 2026

Latest observation

Oct 28, 2026OpenAI APIWeb search: off

A good pattern for searching private content with per-user access control is to treat search as a filtered retrieval problem, not just a text matching problem.

Core idea

When a user searches, only return documents they’re allowed to see. That means your search system needs:

  1. Full-text search over the content
  2. Authorization filter applied at query time
  3. A way to keep permissions indexed efficiently

Common approaches

1) Filter at query time

Store each document with an ACL field, for example:

  • owner_user_id
  • shared_with_user_ids
  • shared_with_group_ids
  • visibility = private/team/org

Then on search:

  • run keyword/vector search
  • filter results by the current user’s permissions

This is the simplest pattern, but the filter must be implemented carefully so unauthorized docs never leak.


2) Precompute access lists

For each document, store an “allowed principals” list:

  • user IDs
  • group IDs
  • org IDs
  • roles

At search time, compute the current user’s principals and query:

  • doc.allowed_principals intersects user.principals

This works well for many apps and search engines that support filtering.


3) Security-trimmed search index

If you’re using a search engine like Elasticsearch/OpenSearch, index permissions alongside content. Then every query includes a mandatory access filter.

This is often called security trimming:

  • search results are ranked normally
  • only accessible docs are returned

Important design rules

Never rely on client-side filtering

Do not return all matching docs to the frontend and hide unauthorized ones in the UI. The backend must enforce access.

Keep authorization data in the same trust boundary

The search index should not be directly queryable by clients. Put an API in front of it.

Be careful with group membership changes

If users can join/leave groups, you need permissions to reflect that quickly:

  • either query against group IDs dynamically
  • or reindex affected documents if you denormalize access data

Recommended data model

A practical schema:

{
  "id": "doc_123",
  "title": "Quarterly report",
  "body": "....",
  "owner_user_id": "user_1",
  "allowed_user_ids": ["user_1", "user_7"],
  "allowed_group_ids": ["group_a"],
  "org_id": "org_9",
  "visibility": "private"
}

At search time, the user context might be:

{
  "user_id": "user_7",
  "group_ids": ["group_a", "group_c"],
  "org_id": "org_9"
}

Then your filter becomes something like:

  • owner_user_id = user_7
  • OR allowed_user_ids contains user_7
  • OR allowed_group_ids intersects ["group_a", "group_c"]
  • OR visibility = org AND org_id = org_9

If you’re using vector search / embeddings

Same rule applies: vector similarity should be computed only over docs the user can access, or results must be filtered before returning.

Best practice:

  • apply access filters in the vector DB if supported
  • otherwise do a post-filter with care, but ensure you fetch enough candidates so valid results aren’t missed

Performance considerations

For large-scale ACLs:

  • avoid huge per-doc user lists if possible
  • prefer group/org-based permissions
  • use bitsets, inverted ACL indexes, or principal-based filtering
  • keep permission checks cheap at query time

Safer architecture

A robust setup is:

  • App DB stores documents and permissions
  • Search index stores searchable content + permission metadata
  • Search API authenticates user
  • Search API injects mandatory authorization filter
  • Results are returned only if authorized

Questions to decide the best approach

  1. How many documents and users do you expect?
  2. Are permissions mostly per-user, per-group, or per-org?
  3. Is this keyword search, vector search, or both?
  4. Do permissions change frequently?
  5. Do you need real-time permission revocation?

If you want, I can help you design:

  • a schema for your exact permission model
  • an Elasticsearch/OpenSearch query pattern
  • a Postgres-based search approach
  • or a vector-search-safe architecture

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (2 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.