When OpenSearch document-level security keeps one index safe for many teams
Document-level security (DLS) decides which documents a role can retrieve, and field-level security (FLS) decides which fields come back in those documents. Teams need DLS when one index holds records for several business units, customers or tenants and each group must see only its own rows, for example a log index where a regional support team should see only events from its region. Teams need FLS when the same documents are visible to a group but some attributes, such as personal identifiers or internal notes, must be hidden from it. The two controls are often used together, and both are configured per role in the OpenSearch Security plugin, which is licensed under the Apache License, Version 2.0. The OpenSearch FAQ does not describe any paid edition of the software, so the controls are available without a separate license purchase. Confirm the current edition and feature details against the FAQ and your own version before you commit to a design.
The reader should understand from the start that these are read controls only. The OpenSearch documentation describes DLS as limiting which documents a role can retrieve through a query filter, and it does not restrict writes. A role that is allowed to index or update documents in a shared index can still write documents outside its DLS query, so write permissions need their own review and separate index or role boundaries. Before rollout, list every role that touches a shared index, check its write and delete privileges, and confirm with a test user that searches return only the expected documents. Plan the verification as part of the design: a missing filter in a role is a data exposure, and the only way to find it reliably is to test each role against known documents. The design work is where most of the risk sits, so document the intended filter for each role and review it with the data owners before the first production query runs.
Which access control fits which requirement
This table compares document-level security, field-level security, field masking, separate indices and separate clusters for OpenSearch. Read each row as a question: what the control restricts, what it leaves open, and when it is the right choice. The main takeaway is that DLS and field-level security govern reads only, so write paths and aggregations need their own review.
| Option | What it restricts | What it does not restrict | When it fits |
|---|---|---|---|
| Document-level security (DLS) | Which documents a role can retrieve, using a query filter defined per role | Writes, and any role with broader access to the same index is unaffected; confirm aggregation behavior in your version | Teams share one index but each should only see their own tenant, region or business unit records |
| Field-level security (FLS) | Which fields in a returned document a role can read | Writes, and the documents themselves stay visible; confirm how it interacts with your query features | Documents must stay visible to a role but some fields, such as personal or internal notes, must be hidden |
| Field masking | Shows a hashed version of selected field values to a role instead of the original | Search on masked values is lost, and masking is not encryption; confirm the masking details in your version | Analysts need to correlate or count records by a sensitive value without seeing the raw value |
| Separate indices | Access at index or alias level, with clear boundaries for mappings, retention and backups | Nothing inside a shared index; cross-index queries can still reach multiple indices if roles allow it | Data sets differ in retention, owners or sensitivity, or need independent lifecycle and snapshot policies |
| Separate clusters | Everything, including nodes, storage, snapshots, admin access and resource use | Little that is shared; costs and operational effort rise with each cluster | Regulatory or contractual boundaries require physical or administrative separation of data |
What document-level security does not restrict
Document-level security filters what a role can retrieve, and nothing more. The cards below cover the controls that sit outside that filter, so each gap can be tested and closed before users depend on the restriction.
Writes are a separate control
A DLS filter does not stop a role from writing. A role limited to a subset of documents can still index, update or delete documents that match its scope, and the filter does not check what the write changes. Model write access as its own permission in the role, using index permissions such as write, index and delete, and review each role for those actions separately. Confirm the current write behavior against the document-level security docs for your version.
DLS docsTest aggregations against the filter
Aggregations, sorts and highlights run on different code paths than a plain search, and each one must be checked against the DLS filter. Run the same aggregation as a restricted user and as an admin, then compare bucket counts and terms. A difference in counts can reveal the existence or volume of hidden documents. Include these queries in your acceptance tests rather than assuming the filter covers them.
Check suggesters and autocomplete
Suggesters and completion fields return terms drawn from indexed content, so a restricted role may see suggestions built from documents it cannot open. Test completion and term suggesters with a restricted user and compare results to what that user can retrieve. Where suggestions leak content from filtered documents, decide whether to remove the suggester for that role or rebuild the field from a restricted source.
Broad index permissions bypass DLS
A second role with broad read access on the same index returns every document. Roles combine, so a user who holds an unrestricted read permission elsewhere sees the full index regardless of the DLS filter on the narrower role. Audit every role and every index pattern that covers the protected indices, including wildcard patterns and aliases, and remove overlapping grants. A review of effective permissions per user is more reliable than reading each role on its own.
Confirm gaps for your version
The behaviors above can change between OpenSearch releases, and the security plugin is updated alongside the core. Before relying on any gap or control, confirm the current behavior in the docs for the version you run, and repeat the tests after each upgrade. Keep a written list of tested query paths and the version each was tested on, so the evidence stays tied to the running system.
Security docsSetting up DLS and FLS roles in the right order
This sequence moves from knowing which data needs protection to proving that each role sees only what it should. Following the order keeps role filters, field rules and identity mappings from being built on assumptions that testing later has to unwind.
Inventory data owners and classifications
The data owner for each index, with the security or privacy lead, lists which indices hold restricted records, which fields are sensitive, and which teams or applications should see which subsets. Write the result as a short table of index, field, classification, owner and intended audience. The step is done when every index that a role will touch has a named owner and a recorded rule for what that owner wants hidden. Most later rework comes from fields that nobody classified before roles were written.
Define document filters for each role
The security engineer writes a query DSL filter for each role that needs restricted document access, in the role definition in the Security configuration. Keep filters simple, since the docs advise simple queries for performance, and avoid filters that depend on fields the role cannot read. The output is a list of roles with their index patterns and filter queries, reviewed by the data owner. Confirm the filter syntax and the 1024 KB configuration limit for DLS against the current OpenSearch security documentation before you commit the file.
Define field includes and excludes
For each role, the engineer lists the fields it may read as an include list or the sensitive fields it must not read as an exclude list, and records any field masking needs separately. Confirm that the field names match the mappings exactly, including nested and multi-field names, because a typo silently leaves a sensitive field visible. The step closes with a per-role field matrix that the data owner signs off. Field-level security controls what is returned, so the matrix is the reference for later testing.
Map identities and backend roles to roles
The identity administrator maps users, backend roles or directory groups to the new roles, using the identity backend already chosen for the cluster, such as SAML, OpenID Connect, LDAP or Active Directory. Each role gets only the identities that have a documented need for it, and no user inherits a broad role through a group that was never reviewed. The output is a mapping file or group list checked against the role matrix. Confirm that group names in the identity provider match the backend role names exactly, since a mismatch means the role never applies.
Grant write permissions separately
The security engineer confirms that each role's write behavior is set through its index permissions and not through the DLS filter, because document-level security limits which documents a role can retrieve and does not restrict writes. Review the allowed actions for every role that can index, update or delete documents, and remove write actions that a read-only role does not need. The step is complete when a written note states, for each role, which actions it can perform and which permissions govern them. Treat any write path as a separate control to test.
Test each role with a dedicated user
The tester creates one dedicated test user per role, mapped only to that role, and runs the same set of searches as each user. Compare hit counts against the expected counts from the data owner's table, and check that the returned fields match the include or exclude list. Include a search for a known restricted document and a search for a sensitive field, and confirm that neither appears. Record the results in a test log with the role version and date. Repeat the tests after any change to a filter, field rule or mapping.
Confirm the sequence with an access review
The security lead and data owners review the test log against the original inventory and the role matrix, then approve the roles for production. They also check that a user who leaves a group loses the role, and that audit logs show the access decisions the organization needs to review. The step is done when every role has a signed approval, a passing test record and a named owner for future changes. Schedule the next review in your own change process, since no review cadence is set by the researched facts.
How a search request passes through role filters
The walk starts when a client sends a search request to the cluster, where authentication maps the user to backend roles and then to OpenSearch roles. The role's DLS query is added to the search as a filter, so only matching documents can be retrieved, and the FLS rules remove fields the role may not see from the response. Writes take a separate path that the DLS filter does not inspect, so check write permissions on the role separately.
Read requests are filtered by role, while write requests bypass DLS.
How filters affect query performance and cluster load
Document-level security adds a query filter to every search a role runs, so the cost of that filter lands on the cluster. The cards below cover where that cost comes from and how to measure it before users depend on the design.
Filter cost grows with index size
A DLS filter is evaluated alongside the user's own query, so a complex filter costs more on a large index than on a small one. Check the expected document count per index, not just the current size, because a filter that is fast today can slow down as the index grows. Ask whether the filter touches fields that are indexed for fast lookup or fields that force scanning of many documents. Measure the filter on the largest index it will guard.
DLS docsKeep DLS queries simple
The OpenSearch documentation advises simple queries for DLS performance. Prefer term or terms matches on keyword fields, such as a tenant or region identifier, over nested boolean trees, wildcards or scripts. Each extra clause runs for every search by every user holding that role. Review each DLS query as production code and reject queries that rely on expensive pattern matching.
Many roles multiply filter work
Each role with its own DLS filter adds work to every request that carries that role. A user with several roles may have several filters combined into one effective restriction, and each adds evaluation cost. Count roles per user and filters per role before rollout. Ask the identity team how many roles a typical analyst or service account receives through group mapping, since mapping growth often goes unnoticed.
Field-level security adds overhead
Field-level security hides selected fields from a role, and it changes what each response contains. Restricting many fields or large fields can add processing to every returned document. Keep the set of hidden fields small and stable, and decide whether a role should see fewer fields or fewer documents, since the two controls have different cost profiles. Confirm the field lists against the mapping for each index before rollout.
Benchmark representative queries
Test the queries that real users and dashboards send, under each role that carries a DLS filter, against data volumes close to production. Record latency, CPU and heap on data nodes during the run. An illustrative test might compare an admin query with the same query under a restricted analyst role, so the cost difference is visible. Repeat the test after mapping changes, reindexing or a new role is added.
Watch the 1024 KB limit
DLS configuration is limited to 1024 KB, so a large set of filters can fail to load or grow hard to review. Track the size of the role definitions as roles accumulate, and treat a growing security configuration as a load and maintenance issue. Ask the team to report the configuration size during each change review so the limit is not reached without warning.
DLS limitsQuestions teams ask before filtering OpenSearch data
Does document-level security cost extra on OpenSearch?
No paid edition is described in the OpenSearch FAQ. All software in the OpenSearch project is released under the Apache License, Version 2.0, and the Security plugin provides role-based access control, document-level and field-level security as part of that open-source stack. Your costs come from the infrastructure that runs the cluster, the staff time to design and test roles, and any outside help you buy. Confirm the license terms for the exact release you plan to run, since the OpenSearch FAQ is the place to check the project's own statements.
How long does setting up document-level security take?
The duration depends on how many roles need a different view of the same index, how clean your field and tenant data is, and how many systems read from the cluster. A single role with one simple filter is a small change. A matrix of teams, regions and data classes, with tests for each combination, takes much longer. Ask any provider for a written scope that lists the roles, indices, identity source and test cases, because those items drive the schedule more than the feature itself.
Can our in-house team configure DLS and field-level security themselves?
Yes, if your team already runs OpenSearch and can read the Security plugin documentation carefully. The main skills are writing query filters that match your data model, testing with real user identities, and checking how dashboards, saved searches and API clients behave under each role. Teams without these skills often underestimate testing. A partner can add value by reviewing the role design, building the test matrix and documenting the result so that the next change is less risky.
What do we need to provide before the work starts?
Expect to supply four things: data owners who can say which documents and fields each group may see, a role matrix that maps teams to indices and access levels, a list of identity groups or backend roles from your directory or identity provider, and test users in a non-production cluster. Data owners resolve most of the ambiguity. Without them, roles tend to be too broad or too narrow, and the test results will not reflect real use.
Which engineering issues should we check before we build the filters?
Check four things first. DLS does not restrict writes, so any role that can index or update documents needs a separate write control. The DLS configuration is limited to 1024 KB, so large role sets need planning. The OpenSearch docs advise simple queries because complex filters slow searches. Finally, field-level security changes what a user sees in responses, not what is stored, so test every client and dashboard that reads the index under each role.
How does DeployOpen scope a fixed-scope engagement and quote it?
DeployOpen works from a written scope. Most engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts. The scope usually covers the indices and roles in question, the identity source, the test plan and the handover documents. The quote follows from that scope, and DeployOpen does not publish a price list. Ask for the assumptions behind the quote, the items you must supply, what is excluded, and what a later change to the role matrix would cost.
Do we need ongoing support after the roles are in place?
Usually yes, because roles change when teams, data classes or applications change. Each new index, field or dashboard needs a decision about who may see it, and each Security plugin upgrade needs a regression check. Ongoing support, upgrades and continuous testing are available as retainers. Ask a provider to state what the retainer includes, how changes are requested and how fast they are handled in writing, since the answer depends on your change volume.
How DeployOpen scopes and delivers OpenSearch access control
DeployOpen scopes OpenSearch document-level and field-level security as a fixed-scope engagement, with the scope agreed in writing before any configuration changes are made in your cluster. The written scope names the indices, the roles that will read them, the query filters and field exclusions each role gets, and the systems that must keep working afterward, such as Dashboards saved objects, ingest pipelines and service accounts. The central artifact is a role matrix that maps every backend role, identity group and API client to its index patterns, DLS queries and FLS field lists, so reviewers can check the design before anything is applied.
Configuration happens inside your own cluster, in your infrastructure, using the files and tooling your team will keep. DeployOpen writes the role definitions and mappings in the Security plugin's YAML format, keeps them in your version control system, and applies them through the Security plugin's admin tooling rather than through ad hoc edits in the UI. Each role is then tested as the account that will hold it. That testing covers the expected results (the right documents returned, excluded fields absent), the negative cases (writes that DLS does not block, which must be handled by index permissions instead), and the query and aggregation paths your dashboards actually use, with timings recorded so slow filters surface before go-live.
Delivery ends with a documented handover: the role matrix, the test scripts and their results, the change procedure for adding a role or index, and a list of decisions still owned by your team, such as which identity groups map to which roles. Ongoing review of roles as teams and indices change is available as a retainer, and that work is priced from the scope agreed for it. Ask any provider to confirm which of these deliverables are included in the fixed scope, who holds the admin certificates after handover, and how role changes will be tested before they reach production.

