Field-Level Security in Elasticsearch

Field-Level Security in Elasticsearch

Learn how Elasticsearch lets different people search the very same documents while each person sees only the fields they are allowed to see, and how to design, test and operate this safely in production.

Picture the front office of a big school. On the desk sits one giant register, and every row is a student. The columns hold the name, the class, the home phone number, the medical notes and the fees paid. The class teacher only needs the name and the class. The accountant only needs the fees. The school nurse only needs the medical notes.

The school could print three separate registers, but then every change must be copied three times, and sooner or later the copies disagree. A smarter idea is to keep one register and cover some columns with sticky paper, depending on who is reading. Everyone works from the same truth, yet nobody sees more than they should. That sticky paper is exactly what Field-Level Security does inside Elasticsearch.

1The Problem: One Index, Many Audiences

Before learning the feature, it helps to feel the pain it removes.

Elasticsearch is a search and analytics engine. It stores data as documents, which are like rows in a table or cards in a card box, and it keeps groups of documents together in an index. Companies love it because it can search millions of documents in a blink. The trouble starts when a single index holds information of very different sensitivity.

Think about a customer index in a bank. Each document may hold a customer name, a city, an account type, a phone number, a tax identifier and a risk score. The marketing team wants the city and the account type. The fraud team wants the risk score. The call-centre agent needs the name and phone number to help a caller. Almost nobody needs everything, and handing everything to everybody is a data-leak waiting to happen.

Simple Analogy

A hospital keeps one patient file. The receptionist sees the name and appointment time, the doctor sees the full medical history, and the billing clerk sees the insurance details. Nobody photocopies the file three times. The system simply decides which pages each person may open.

The two clumsy solutions people try first

The first clumsy solution is to make many copies of the data, one index per audience, each with only the allowed fields. This works, but it multiplies storage, doubles the indexing work, and creates the risk that the copies drift apart. If a customer changes their phone number, you must update every copy.

The second clumsy solution is to trust the application. The application sits in front of Elasticsearch, fetches everything, and removes the secret fields before showing the result. That is fragile. One forgotten filter in one new screen, or one developer who queries Elasticsearch directly, and the secret field is exposed.

1 copy
of the data to keep in sync
Many views
one per role or audience
Server side
rules enforced by the cluster itself

Field-Level Security, often shortened to FLS, solves both problems. The rules live inside the Elasticsearch cluster, attached to roles, so every path into the data obeys them, whether the request came from a web app, a dashboard, a script or a curious engineer with a command line.

2What Is Field-Level Security?

A plain definition first, then the vocabulary you will keep meeting.

Field-Level Security is an Elasticsearch feature that controls which fields of a document a user is allowed to read. You attach a list of permitted fields to a role. When a person holding that role searches, Elasticsearch behaves as if the forbidden fields do not exist at all for that person.

Notice the wording “do not exist”. This is stronger than simply hiding a field in the final output. The forbidden field cannot be read in the results, cannot be used inside a query to filter documents, cannot be used to sort, and cannot be counted in an aggregation. That single design choice is what makes FLS trustworthy, and we will return to it many times.

Words you need to know

Term 1

Field

One named piece of data inside a document, such as salary or customer.phone. It is like one column in a register.

Term 2

Document

One stored record made of many fields. It is like one full row or one full card.

Term 3

Index

A named collection of similar documents. It is like a whole register or a whole drawer of cards.

Term 4

Role

A named bundle of permissions, such as “hr-viewer”. Permissions are given to roles, and roles are given to people.

Term 5

Grant list

The list of field names, or patterns, a role is allowed to see. Anything not matched by it is invisible.

Term 6

Except list

A list of fields to remove from what the grant list allowed. It carves holes in a wide permission.

Where does FLS sit in the bigger picture?

Elasticsearch offers security in layers. The outer layer decides whether you may talk to the cluster at all. The next layer decides which indices you may touch. FLS is a finer layer that works inside an index and decides which columns you may read. A sibling feature called Document-Level Security works on rows instead of columns. Together they let you cut a single index both horizontally and vertically.

i
Licensing note

Field-Level Security and Document-Level Security are part of Elastic’s paid subscription features rather than the free basic tier. Subscription packaging changes over time, so always confirm on the official Elastic subscription page which tier your deployment needs before you design around FLS.

“The best secret is the one a user cannot even ask about.”

3The Security Building Blocks Underneath

FLS does not stand alone. It is one setting inside Elasticsearch’s role-based access control.

To understand where the field rules live, you need a quick tour of how Elasticsearch decides who can do what. The system has two separate questions. The first is authentication: who are you? The second is authorization: what are you allowed to do? FLS belongs to the second question.

Authentication: proving who you are

Elasticsearch checks your identity through a realm. A realm is simply a source of identities. It can be the built-in native user store, a file, an LDAP or Active Directory directory, a single sign-on system using SAML or OpenID Connect, or an API key. Whichever realm accepts you, the result is the same: Elasticsearch now knows a username and a set of roles.

Authorization: role-based access control

Elasticsearch uses role-based access control, usually written as RBAC. Instead of giving permissions to each person one by one, you give permissions to roles and then attach roles to people. When the accounting team grows from four people to forty, you only add forty names to one role.

Simple Analogy

Think of a hotel. Guests receive keycards. A card for a standard room opens the front door, the lift and that one room. A card for the manager opens many more doors. The card is the role, the doors are the privileges, and FLS is a rule that says “this card may open the wardrobe but not the safe inside the wardrobe”.

What a role can contain

Part 1

Cluster privileges

Permissions about the whole cluster, such as monitoring its health or managing snapshots.

Part 2

Index privileges

Permissions on named indices, data streams or aliases, such as read, write or create. FLS lives here.

Part 3

Application privileges

Permissions understood by other applications, for example features inside Kibana.

Part 4

Run-as

Permission to act on behalf of another user, which is very useful for testing what someone else would see.

The key point is that field security is a property of an index privilege entry. A role says: “for indices matching these names, allow these actions, and only on these fields”. So the same role can be strict on one index and relaxed on another.

Role mapping: connecting people to roles

When your users come from an outside directory or single sign-on, you use role mappings. A role mapping is a rule such as “anyone in the finance group gets the finance-reader role”. This means FLS scales to large companies, because the identity team manages group membership and the search team manages roles.

!
Common misconception

Many beginners think FLS is about logging in. It is not. FLS never decides who may enter. It only reshapes what an already-authenticated, already-authorized user sees inside the indices they can read.

4Writing the Rules: Grant and Except

The whole feature comes down to two small lists.

Inside an index privilege entry, the field rules are stored in a section called field_security. It has two parts: grant and except. You will usually create them in Kibana’s role screen or through the security API, but the ideas are the same in both places.

The grant list

The grant list names the fields the role may see. Names can be exact, such as name, or they can use a wildcard, such as address.*, which means “everything below address”. A single star means “every field”. If a role has no field security section at all, the role sees every field, so leaving it out is a wide-open choice.

An empty grant list is the opposite extreme. It means no ordinary fields are visible. System-managed metadata, such as the document identifier and the index name, remains available, because Elasticsearch needs it to function.

The except list

The except list removes fields from what the grant list allowed. It exists because it is often easier to say “everything except three secret fields” than to list two hundred safe ones. You combine a broad grant with a narrow except.

What you wantGrant list saysExcept list saysResult for the user
Everything visiblea single staremptyAll fields
Hide two secret fieldsa single starthe two field namesAll fields except those two
Allow only a short safe listthe safe field namesemptyOnly those fields
Allow a whole group of fieldsa name followed by dot-staremptyThat object and everything below it
Allow a group but hide one parta name followed by dot-starone specific child fieldThe group minus that child
Show no ordinary fieldsemptyemptyOnly metadata

Two styles of thinking: allow-list and deny-list

The first style is the allow-list. You name only the fields that are safe and everything else is hidden. This is the safer style, because when a developer adds a new sensitive field next month, it stays hidden by default. The second style is the deny-list. You allow everything and hide named fields. This is convenient, but a newly added secret field is visible to everybody until someone remembers to update the role.

!
Common mistake

Fields inside objects, and the extra sub-fields that Elasticsearch creates for one piece of text (for example a searchable version and an exact-match version), each have their own path name. Do not assume that granting the parent automatically covers every child. Use a wildcard pattern that clearly covers the family of names, then test with a real user.

i
Practical tip

Prefer allow-lists for sensitive data such as health, payroll and identity numbers. Use deny-lists only for low-risk data where the convenience is worth the small chance of a missed new field.

5Internal Working: How Elasticsearch Hides a Field

Understanding the mechanism explains every surprising behaviour you will meet later.

Elasticsearch is built on a library called Lucene. Each index is split into pieces called shards, and each shard is a small Lucene index. When you search, every shard reads its own data and returns matches. FLS works at this low level, right where data is read from disk.

A wrapper around the reader

When a user with field rules searches a shard, Elasticsearch wraps the normal reader in a special filtering reader. This wrapper looks at the user’s allowed field names and behaves as if any other field is not part of the index. When the search code asks “does this field exist?”, the wrapper answers no for forbidden fields. When the code asks for stored values, the wrapper leaves out the forbidden ones.

Simple Analogy

Imagine a librarian who reads from a catalogue on your behalf. Before you sit down, someone gives the librarian a version of the catalogue with certain columns blacked out. The librarian is honest and follows the catalogue exactly, so when you ask about a blacked-out column the librarian truthfully replies that no such column exists.

flowchart TD
    A["Search request arrives with user identity"] --> B["Security layer finds the user's roles"]
    B --> C["Roles combined into allowed field patterns for the index"]
    C --> D["Each shard wraps its reader with a field filter"]
    D --> E["Query, sort and aggregation see only allowed fields"]
    E --> F["Stored source is trimmed to allowed fields"]
    F --> G["Coordinating node merges shard results"]
    G --> H["User receives a reduced response"]
        
FIG 1 — How a field rule travels from the role down to each shard

The diagram shows an important idea. The filtering does not happen at the very end on the assembled answer. It happens inside every shard, before matching, scoring and aggregating. That is why hidden fields cannot leak through side doors such as a filter or a bucket count.

The trimmed source document

Elasticsearch stores the original JSON of each document in a special field called _source. When you fetch a document or run a search, this is usually what you see returned. With FLS active, the source is rebuilt on the fly so that it contains only allowed fields. The stored original is untouched; only the copy handed to that user is trimmed.

Why security is decided before matching

Suppose the field filter were applied only on the final output. A clever user could then type a search like “salary greater than 100000” and learn, from which documents came back, who earns a lot, even though the salary column was never shown. By hiding the field from the query engine itself, Elasticsearch treats that search as a query on a non-existent field, which matches nothing useful.

i
Key insight

FLS is not cosmetic. It changes what the search engine believes exists for that user. This is the difference between a real security control and a screen-level mask.

6Data Flow and Lifecycle of a Protected Request

Follow one request from the keyboard to the screen.

Let us walk through what happens when an HR analyst named Meera searches an employee index. Her role allows the name, department and job title, but not the salary or the home address.

1

Meera signs in

Her company single sign-on system proves her identity. Elasticsearch learns her username and maps her group membership to the analyst role.

2

She sends a search

Through Kibana or an application, she asks for employees in the engineering department.

3

The cluster checks index access

Elasticsearch confirms that her role has the read privilege on the employee index. If not, the request stops here with a denial.

4

Field rules are resolved

The allowed field patterns for that index are calculated from all of her roles and sent along with the request to each shard.

5

Shards search through the filter

Every shard searches only allowed fields, scores the matches, and prepares trimmed source documents.

6

Results are merged and returned

One node collects the shard answers and returns a single response. Meera sees names, departments and titles, and nothing else.

sequenceDiagram
    participant U as Analyst
    participant K as Kibana or App
    participant E as Elasticsearch Security
    participant S as Shards
    U->>K: Search engineering staff
    K->>E: Request with credentials
    E->>E: Authenticate and load roles
    E->>E: Check index privilege and field rules
    E->>S: Search with field filter attached
    S-->>E: Matches with trimmed source
    E-->>K: Combined response
    K-->>U: Name, department, title only
        
FIG 2 — Sequence of a protected search

What happens when the rules change?

Roles are stored inside the cluster and cached by the security layer. When an administrator edits a role, Elasticsearch clears the cached copy so that new requests pick up the change. You do not need to reindex data or restart anything, because field rules are only a lens applied at read time. This makes it cheap to fix a mistake quickly.

7What Gets Hidden, and Where It Shows Up

A tour of every place a hidden field might try to appear.

A good security control has no back doors. Here is how FLS treats the many ways a client can read data from Elasticsearch.

Where the field could appearWhat the restricted user experiences
Search results and the returned sourceForbidden fields are missing from the returned document
Fetching one document by identifierThe same trimmed view as search
Filtering with a query on the fieldBehaves as if the field does not exist, so it matches nothing useful
Sorting on the fieldNot possible, because the field is unknown to that user
Aggregations such as sums, averages and bucketsCannot be computed on hidden fields
Highlighting matched textOnly allowed fields can be highlighted
Reading the index mappingThe mapping lists only the fields the user may see
Asking which fields existHidden fields are not reported
Kibana screens and data viewsField lists and Discover show only permitted fields

The mapping is filtered too

A mapping is Elasticsearch’s description of an index: which fields exist and what type each one has. If the mapping still listed a field called salary, the user would at least learn that salary data exists. With FLS, the mapping shown to the user leaves such fields out, so even the existence of the field is not revealed.

What FLS does not change

Some things stay the same for everyone. The total number of documents an index holds is not altered by hiding a field, because FLS hides columns, not rows. If you want some documents to disappear for some users, you need Document-Level Security. Also, system metadata such as the document identifier, index name and routing value remains visible.

!
Watch out

Sensitive information can hide inside fields you consider harmless. A document identifier built from a national ID number, or a free-text notes field where staff type medical details, will pass through any field rule that allows it. FLS protects field names, not what people typed inside allowed fields.

8FLS, DLS and Index-Level Security Compared

Three cutting tools, three different shapes of cut.

Elasticsearch gives you three levels of data restriction. Beginners often mix them up, so let us separate them clearly.

Level 1

Index-level security

Decides which whole indices a user may touch. It is like deciding which cupboards in the office a person may open.

Level 2

Document-level security

Decides which rows inside an index are visible, using a query attached to the role. It is like a folder where some sheets are removed.

Level 3

Field-level security

Decides which columns inside the visible rows can be read. It is like sticky paper over some columns.

QuestionIndex-levelDocument-levelField-level
What does it limit?Whole indicesRowsColumns
How is it defined?Index name patterns and privilegesA query inside the roleGrant and except lists
Example useOnly the sales team reads the sales indexEach regional manager sees only their regionSupport staff cannot see card details
GranularityCoarseMediumFine
Extra work at read timeVery smallQuery evaluation and cachingFiltering of fields

Using them together

The real power appears when you combine them. Imagine a shared index of support tickets from many customer companies. Index-level security lets the support team read the ticket index. Document-level security limits each agent to tickets from their assigned customers. Field-level security hides the internal cost and margin notes from everyone except managers. One index, three lenses, no duplication.

“Index rules choose the room, document rules choose the shelf, field rules choose the words on the page.”
i
How to choose

Ask three questions in order. Should this person touch this index at all? If yes, should they see every row? If yes, should they see every column? Each “no” tells you which control to add.

9When a User Has More Than One Role

Real people wear many hats, and Elasticsearch has to combine their permissions.

In a real company, one person often belongs to several groups. A data analyst may also be a member of the finance reviewers group. Each group maps to a role, so the person ends up holding several roles at once. Elasticsearch must then decide what the person can see when two roles say different things about the same index.

The additive rule

Permissions in Elasticsearch are additive. There is no “deny” rule that beats an “allow” rule. If any one role grants access to a field, the person can see that field. In other words, the field permissions from the different roles are combined into a union.

Simple Analogy

Suppose you carry two keychains. One opens the storeroom and the other opens the staff kitchen. You are not blocked from the kitchen just because the storeroom keychain does not fit. You can open everything that either keychain opens.

graph LR
    R1["Role A grants name and city"] --> U["Combined view for the user"]
    R2["Role B grants city and balance"] --> U
    U --> V["User sees name, city and balance"]
        
FIG 3 — Field permissions from several roles are merged

The trap of the wide role

Here is the part that surprises many teams. If one of the user’s roles has no field restriction at all on an index, that role is effectively granting every field. Because permissions add up, the restricted role can no longer protect anything. A single forgotten broad role can undo careful work in ten other roles.

Mixing document and field rules across roles

The same additive thinking applies when roles mix row rules and column rules. In general, the user gets the documents any role allows and the fields any role allows, and you should not assume that a field granted by one role stays tied to only the documents that same role allowed. When a user holds several roles with different row and column rules on the same index, the combined outcome can be wider than any single role intended.

!
Design warning

Do not rely on subtle interactions between roles. Keep roles small, purpose-specific and easy to reason about. When you must combine row and column rules across several roles on one index, test with a real user account and read the actual results before you trust the design.

i
Practical tip

Create one role per job function, such as “support-agent” or “finance-auditor”, rather than one role per person. Review which people hold more than one role, because those are the accounts where surprises appear.

10Real-World Examples

The same technique protects very different kinds of data across industries.

Healthcare records

A hospital indexes patient visits for fast search. Reception staff see the patient name, appointment slot and doctor. Nurses also see vitals and allergy notes. Only treating doctors see diagnoses and clinical notes. One index serves everyone, and privacy rules such as those in health-data regulations are respected through role design.

Banking and payments

A bank stores transaction documents with account numbers, merchant names, amounts and device fingerprints. Customer-support staff see merchant and amount to answer a caller’s question. The fraud team sees the device fingerprint and risk score. Nobody outside a small compliance group can read full account numbers.

Human resources analytics

An HR platform keeps employee documents with department, title, manager, salary and performance rating. Managers browse the organisation chart fields. HR business partners also see ratings. Only the payroll team sees salary. The company runs company-wide dashboards on the same index without leaking pay.

Multi-tenant software products

A software company logs customer activity in one shared index. Customer-facing dashboards show usage fields only. Internal engineers can see technical fields such as internal server names. Cost and margin fields are visible only to finance. The product team avoids building a separate index for every audience.

E-commerce and retail

An online shop indexes orders. Warehouse staff need item names, quantities and delivery addresses. Marketing analysts need product category and order value but not the address or phone number. Finance needs payment status. Each group searches the same order index through its own view.

Security operations centres

Security teams index log events from many systems. Junior analysts triage alerts using event type and severity. Senior investigators additionally see user names and source addresses. This limits who can connect an alert to a real person, which supports privacy policies inside the company itself.

Health
clinical notes shown only to treating staff
Finance
account numbers shown only to compliance
HR
pay fields shown only to payroll

11Designing a Field Security Model Step by Step

A repeatable method that works for any dataset.

Good FLS is more about thinking than typing. The steps below turn a messy “who should see what” conversation into a clean set of roles.

1

Inventory the fields

List every field in the index, including nested ones and any that will be added soon. Note the business meaning of each field in plain words.

2

Classify sensitivity

Sort fields into simple groups such as public, internal, confidential and restricted. Ask the data owner, not only the developer, because owners know the legal impact.

3

List the audiences

Write down every job function that will read the index, and what each one needs to do their work. Aim for the minimum, not the convenient maximum.

4

Build the access matrix

Draw a grid with audiences down the side and field groups across the top. Mark where each audience may read. This grid becomes your role definitions.

5

Create roles with allow-lists

Turn each row of the grid into one role that lists exactly the allowed fields. Choose clear names that describe the job, not the person.

6

Connect people through mappings

Use role mappings so group membership in your identity system decides the roles. This keeps ownership with the team that already manages people.

7

Test as each audience

Create test accounts, or use the run-as capability, and try searches, aggregations, filters and mapping requests. Verify that hidden fields are truly absent everywhere.

8

Review on a schedule

When developers add fields or teams change, the model must change too. Schedule a regular review and connect it to your release process.

i
Testing tip

Always test the negative case. It is easy to confirm that allowed fields appear. The real risk is a forbidden field appearing somewhere unexpected, such as inside a multi-field, a highlighted snippet or a dashboard tooltip.

12Security Considerations and Limitations

Know what FLS protects, and just as important, what it does not.

FLS is about reading, not writing

Field-Level Security is a read-side control. It shapes what a user sees when reading. It is meant to be used with read-oriented privileges, and combining it with powerful write privileges on the same index is discouraged. Some write style operations, most notably the update-by-document operation, are not allowed when field or document security is active on the index, because a partial view of a document cannot safely be merged back into the full document.

Copying data can escape the filter

Anyone who can read data can, in principle, copy what they see to a new place. A user allowed to see a name and a phone number can export those two fields into a spreadsheet. FLS controls the view, but it does not stop authorized users from sharing what they legitimately saw. Policies, training and export controls must cover that human side.

Powerful roles bypass everything

Superuser accounts and roles with broad administrative privileges are not limited in the way normal read roles are. Anyone who can edit roles can also give themselves more access. Guard these accounts with strong authentication, keep the list very short, and record what they do.

The data on disk is not encrypted by FLS

FLS decides what a query can return. It does not encrypt shard files, snapshots or backups. Someone with access to the machine, a disk image or a snapshot repository could read the raw data. Protect these with disk encryption, network controls and strict access to the storage layer.

!
Hidden risk

Values can leak through allowed fields. Free-text fields, log messages, URLs and document identifiers often contain the very data you meant to hide, such as an email address inside a URL. Review allowed fields for accidental sensitive content, and clean data before indexing when possible.

No built-in masking

FLS either shows a field or hides it. It does not show a partially masked value such as the last four digits of a card. If you need masking, prepare a separate masked field when the data is indexed, for instance with an ingest pipeline, and then grant the masked field to broad audiences while keeping the full field restricted.

Other features to double check

Cross-cluster search, reindexing, data views in Kibana and features that copy or transform data each have their own rules about how field and document security apply. Before relying on FLS in a new workflow, read the documentation for that feature in your exact version, and test it with a restricted user. Behaviour can differ between versions, so retest after upgrades.

13Performance, Monitoring and Auditing

A security feature should be observable and should not slow the business down.

Performance in plain words

Because FLS puts a filter around the reader, every request from a restricted user does a little extra work. For typical role definitions this cost is small compared with the cost of the search itself. The cost grows when role definitions are complicated, with very many overlapping wildcard patterns, or when a user holds many roles that all have to be merged. Simple, clean role definitions are both easier to understand and cheaper to run.

Habit 1

Keep patterns simple

Use a small number of clear wildcard patterns instead of hundreds of similar entries.

Habit 2

Limit role stacking

Fewer roles per user means less merging work and easier reasoning about the outcome.

Habit 3

Measure before and after

Compare search latency for a privileged user and a restricted user on the same query, in a test environment.

Habit 4

Watch heavy aggregations

Large aggregations on restricted indices deserve the same monitoring as any expensive query.

Auditing who accessed what

Elasticsearch can write audit logs that record security events such as successful logins, failed logins, access granted and access denied. These logs tell you which user touched which index and when. In general they record the request and its outcome rather than listing which individual fields were filtered out, so pair them with a good role review process.

What to monitor

Watch for repeated access-denied events, which may signal a misconfigured application or a person probing the system. Watch for changes to role definitions, because role edits are the moment a careful design can be quietly weakened. Send audit logs to a separate protected place so that an administrator cannot easily erase their own footprints.

i
Operations tip

Store role definitions in version control as a reviewed source of truth and apply them through automation. Then every change has an author, a reason and a history, and rolling back a bad change is simple.

14Design Patterns and Anti-Patterns

Habits that age well, and habits that cause incidents.

Patterns worth copying

Pattern 1

Tiered roles

Create a basic, an extended and a full role for the same index. Each tier adds a small set of fields, so people choose the lowest tier that fits.

Pattern 2

Sensitive fields under one prefix

Store restricted data under a shared object name, such as a “private” group. One wildcard rule then protects all current and future fields inside it.

Pattern 3

Masked twin fields

Index a redacted version of a sensitive value next to the original. Broad roles receive the masked twin, while narrow roles receive the original.

Pattern 4

Alias per audience

Give each audience an alias name to search through, and grant roles on the alias. Applications never need to know the real index names.

Pattern 5

Roles as reviewed configuration

Keep role definitions in a repository, review changes like code, and deploy them automatically.

Pattern 6

Row plus column together

Combine document-level and field-level rules in one purpose-specific role so that each audience gets a clear, single-source view.

Anti-patterns to avoid

ANTI-PATTERN-01 Avoid
Problem

The team writes a wide “allow everything” grant and hides a handful of known secret fields with an except list, and calls the job done.

Why It’s Harmful

Every field added in future is visible by default. A developer adds a new field holding a national identifier, nobody updates the role, and the field is exposed to everyone for months.

Correct Approach

Use an allow-list for sensitive indices. Name only the fields each audience needs. New fields stay hidden until someone consciously grants them.

ANTI-PATTERN-02 Avoid
Problem

A shared “power user” role with no field restrictions is handed to many people for convenience, alongside their normal restricted roles.

Why It’s Harmful

Permissions add up, so the unrestricted role silently cancels the protection of every other role the person holds. The careful design exists on paper only.

Correct Approach

Keep unrestricted access to a tiny, named group. Give everyone else purpose-specific roles, and audit which accounts hold broad roles.

ANTI-PATTERN-03 Avoid
Problem

The team trusts the application to remove secret fields and treats FLS as an optional extra, or the other way around, relies on FLS and ignores the sensitive text typed inside allowed fields.

Why It’s Harmful

Either layer alone has gaps. The application can be bypassed by a direct query, and FLS cannot understand the meaning of text inside a field it allows.

Correct Approach

Enforce access in the cluster with FLS, and also clean or restructure sensitive content before it is indexed. Use both layers and check them both.

FLS versus other approaches

ApproachStrengthWeakness
Field-Level SecurityOne copy of data, rules enforced inside the clusterNeeds a paid subscription tier and careful role design
Separate index per audienceSimple to understand and strongly separatedDuplicated storage and risk of copies drifting apart
Application-side filteringFlexible and easy to changeAny path around the application exposes everything
Redaction during ingestionThe sensitive data never enters the indexThe original values cannot be recovered for the people who do need them

15Advantages and Trade-offs

An honest look at what you gain and what you pay.

Advantages

  • One copy of the data serves many audiences, which saves storage and avoids drift.
  • Rules are enforced by the cluster, so every client path obeys them.
  • Hidden fields cannot be queried, sorted or aggregated, which closes common side channels.
  • Changes take effect without reindexing, so fixes are quick.
  • Role mappings connect naturally to company directories and single sign-on.
  • Supports compliance goals such as data minimisation and need-to-know access.

Disadvantages / Trade-offs

  • Requires a paid subscription tier.
  • Additive roles make combined permissions easy to misjudge.
  • No built-in masking of partial values.
  • Some write-style operations are restricted on protected indices.
  • Does not encrypt data on disk or in snapshots.
  • Needs ongoing review as schemas change and new fields appear.

16Best Practices and Common Mistakes

A short checklist you can print and pin next to your desk.

Best practices

1

Start from least privilege

Begin with no access and add fields only when someone proves they need them for their work.

2

Prefer allow-lists on sensitive indices

Make new fields hidden by default, so growth in the schema cannot turn into a leak.

3

Design the schema with security in mind

Group sensitive fields under clear names so that a single pattern can protect them.

4

Test with real restricted accounts

Check search, aggregations, sorting, highlighting, mappings and dashboards, not only the main screen.

5

Audit roles and people regularly

Look for wide roles, unused roles and people who hold many roles. Remove what nobody needs.

6

Combine with encryption and network controls

Treat FLS as one layer in a defence that also covers transport encryption, disk encryption and restricted infrastructure access.

Common mistakes

Forgetting sub-fields

Granting a text field but forgetting the extra exact-match version of it, so dashboards suddenly break for restricted users, or the opposite, exposing a version you meant to hide.

Assuming an empty section means safe

Leaving field security out of a role means every field is allowed. Silence is not protection.

Testing only as an administrator

An administrator sees everything, so tests as an administrator prove nothing. Always test as the restricted user.

Ignoring the identifier

Building document identifiers from personal data, which then appear in every response regardless of field rules.

Never retesting after upgrades

Security behaviour can change between versions. Include restricted-user tests in your upgrade checklist.

17Frequently Asked Questions

Quick answers to the doubts beginners raise most often.

Q1Is Field-Level Security free?

It is part of Elastic’s paid subscription features, not the free basic tier. Check the current subscription comparison for the exact tier your version and deployment type requires.

Q2Does FLS delete or change my stored data?

No. The stored documents are unchanged. FLS only changes what a particular user is allowed to read at query time.

Q3Can a user guess a hidden value by filtering on it?

No. A hidden field is treated as if it does not exist for that user, so filters, sorts and aggregations on it do not reveal anything.

Q4What is the difference between FLS and DLS?

FLS hides columns, meaning specific fields. DLS hides rows, meaning whole documents, based on a query stored in the role. They are often used together.

Q5If a user has two roles with different field rules, which one wins?

Neither wins. Permissions are additive, so the user gets the combined set of fields from all roles. If one role has no field restriction, the user can see every field.

Q6Do I need to reindex when I change a role?

No. Field rules are applied when data is read, so an edited role takes effect for new requests without touching the stored data.

Q7Can FLS show only part of a value, like the last four digits?

Not by itself. A field is either visible or hidden. For partial masking, create a masked field when the data is indexed and grant that field to the broader audience.

Q8Does FLS protect me if someone steals a backup or snapshot?

No. FLS works when data is queried through Elasticsearch. Protect raw files and snapshots with encryption and strict storage permissions.

Q9Does it work with Kibana dashboards?

Yes. Kibana talks to Elasticsearch as the signed-in user, so dashboards and Discover show only the fields that person may read. A visualization that depends on a hidden field will show empty or partial results for them.

Q10How can I test what another person would see?

Create a test user with the same roles, or use the run-as privilege to send requests on that person’s behalf, and inspect the results, the mapping and any dashboards.

18Summary and Key Takeaways

Field-Level Security lets one Elasticsearch index serve many audiences without duplicating data. Rules are written as grant and except lists inside roles, enforced deep in each shard, and applied to results, queries, sorting, aggregations and mappings alike. Used with document-level rules and good role design, it turns “everyone sees everything” into “everyone sees what their job needs”. Its strength depends on careful design: allow-lists, small purpose-driven roles, honest testing as restricted users, and regular review.

Key Takeaways

  • FLS controls columns — it decides which fields inside an index each role can read, while document-level security controls rows.
  • Hidden means non-existent — forbidden fields cannot be read, queried, sorted, aggregated or seen in mappings by that user.
  • Grant and except — two simple lists, ideally written as allow-lists for sensitive data so new fields stay hidden by default.
  • Permissions add up — a user with several roles gets the union of fields, so one wide role can undo many careful ones.
  • It is not encryption or masking — protect disks and snapshots separately, and prepare masked fields at indexing time if partial values are needed.
  • Test as the restricted user — verify search, aggregations, mappings and dashboards, and retest after upgrades and schema changes.
  • Treat roles as living configuration — keep them in version control, review them on a schedule and audit who holds broad access.