Search Inside a Business App: Filters and Permissions — Integrations & APIs article by Rui Codex

Search inside a business application should combine structured filters for exact conditions, full-text search for free-text matching, and permission checks applied before any result is returned. Enforce the permission rules in the query itself rather than in the display layer, so restricted records never leave the database and cannot be counted, sorted or suggested.

Key takeaways

  • Filters answer questions about known fields and values, while full-text search matches the words a user remembers.
  • Permissions must be enforced inside the query, so restricted records never reach the result list, the count or the facets.
  • Search indexes lag behind changes to records, which makes data freshness a design decision rather than a default.
  • Every role should be tested with the same queries, because a result list that looks correct for an administrator can expose data to other users.

What must search inside a business application do?

Search in a business application has three jobs: narrow a known set of records, match wording the user cannot map to a field, and hide everything the user is not allowed to see. Each job has a different implementation, and they interact. A filter that ignores permissions is wrong even when it is fast, and a relevance ranking that surfaces a restricted document is a data leak even when the ranking is good.

Most business data is spread across tables that were designed for transactions, not for lookup. Orders reference customers, invoices reference orders, and notes sit in free-text fields attached to any of them. Search has to traverse those relationships without making the user build a join by hand. That is why search is an engineering concern and not only a user-interface feature.

For operations and IT leads, the practical question is which queries users really run. Typical requests are a status plus an owner, a customer name typed loosely, or a reference number copied from an email. Designing for those requests first keeps the search surface small and testable. Rui Codex builds search as part of custom software and system integrations, and the same principles apply whether the data lives in one database or across several connected systems. You can read more about our approach on the custom software development service page.

When should you use filters instead of full-text search?

Use filters when the question has a known field and a known value, such as status, owner, region or a date range. Use full-text search when the user types words from memory, such as part of a company name, a phrase from a note or a description. Most good screens offer both, with filters as the primary narrowing tool.

How filters behave

A filter maps to a condition on an indexed column. Several filters combine with AND, the result is predictable, and it is easy to explain to users and auditors. The engineering work lies in choosing indexes that match the combinations people actually use. A single index on status helps little when every query also filters by owner and date, and the database falls back to scanning rows.

Filters fail when the set of optional conditions grows without limit. Each new combination is a new query shape, and performance problems appear only under real data volumes. Keep the filter list short, fix the defaults, and review the slowest combinations after release.

How full-text search behaves

Full-text search splits text into tokens, normalises them, and ranks matches. PostgreSQL, for example, documents its built-in full-text search with text search types and functions in its official manual. Stemming, stop words and dictionaries decide whether a search for a plural finds the singular, and those choices are configurable and need testing with your own vocabulary.

Full-text search fails in predictable places. Product codes and reference numbers get split into fragments, names with accents match inconsistently, and relevance ranking favours long text fields over short, precise ones. Full-text search is also a poor replacement for an exact lookup. Use it for discovery, and keep exact identifiers on a dedicated filter.

Tip: Store reference numbers in a normalised field and search them with an exact match first, falling back to full-text only when that returns nothing.

Permissions should restrict the candidate set before ranking, counting and pagination. If the database returns a page of results and the application removes the restricted ones afterwards, the page is too short, the total count is wrong and the facet counts reveal what exists. Even a count of matching documents can disclose information to someone who should not see them.

Leaks also happen outside the main result list. Autocomplete suggestions can show customer names, facet panels can show counts by supplier, and error messages can echo record identifiers. Each of these surfaces needs the same permission logic as the main query. The OWASP Authorization Cheat Sheet recommends checking authorisation on every access to a resource, not only at the entry point of a page, and that advice applies directly to search endpoints. The OWASP Authorization Cheat Sheet is a useful reference for these checks.

Permission rules come in several shapes: role-based access, ownership, team membership and attribute rules such as region. Combining them can produce complex predicates. Keep the rules in one place, have search call that same function or view that the detail page uses, and avoid writing a second copy inside the search code. Duplicated rules drift apart over time, and drift is how restricted records become visible.

Tip: Write a test that runs the same query as two different roles and asserts that the restricted role never sees a record, a count or a suggestion it should not see.

What are the trade-offs between database search and a search engine?

Start with database indexes and built-in full-text search when the data lives in one system and query volume is moderate. Move to a dedicated search engine when you need cross-system search, advanced relevance tuning or heavy query load. The table below compares the options using qualitative criteria only.

CriterionDatabase indexes and full-textDedicated search engine
Setup effortLow, within the existing databaseHigher, a separate service to run
Data freshnessUsually immediate on writeDepends on the sync pipeline
Permission handlingSimple to keep in one queryRequires permission data in the index
Relevance tuningAdequate for most internal lookupsRicher ranking controls
Operational loadShares resources with the applicationSeparate scaling and monitoring

The permission row deserves attention. A search engine index holds copies of records, so it must also hold access information or query it at search time. Each copy has to stay in step with the source. A sync delay can show a record to someone after access has been removed, which makes the freshness and permission questions the same question.

Where does search inside a business app fail?

Most failures come from three sources: stale indexes, permission logic duplicated across code paths, and queries that combine many optional filters. Each one looks harmless in a demo with a few records and becomes visible only in production data.

  • Index updates that run in a nightly batch, so new or corrected records are missing for hours.
  • Soft-deleted or archived records that still appear in full-text results because the index was not told about the change.
  • Facet counts computed before permission filters are applied.
  • Sorting by a field that is not indexed, which works for small tables and times out for large ones.
  • Search that runs as a service account, bypassing the user's own permissions entirely.

Each of these failures is cheap to prevent at design time and expensive to fix after users depend on the screen. Review them as part of the design, not as a bug list after launch.

Hypothetical examples

Here are two hypothetical scenarios:

A field service team searching jobs

A team lead needs jobs filtered by technician and date, and technicians need to find jobs by a customer name typed loosely. The filters use indexed columns for technician and date. The customer-name search uses full-text with a fallback for partial matches. Technicians see only jobs assigned to their own team, and the same team rule is applied to the count and to the suggestions.

A purchasing department searching supplier documents

A purchasing team wants to find contracts by supplier and by a phrase from the clause text. Exact supplier filters use an identifier field, and clause search uses full-text. Documents marked as restricted to the legal group are excluded in the query itself, so the team never sees a count that includes them. When a document is archived, the search index is updated in the same transaction that archives it, so the result list does not show stale entries.

How do you check search before release?

Test search with each role and each permission rule, using the same queries and comparing the results against the permission matrix. Check the following before release.

  • Every search endpoint, suggestion endpoint and export applies the same permission function as the detail page.
  • Counts, facets and pagination are computed after permission filters.
  • Index updates happen on create, update and delete, and you have measured the delay between a write and a visible result.
  • Exact identifiers use a filter, and full-text is used for discovery only.
  • Your slowest filter combinations have been measured with realistic data volumes.
  • Error messages do not echo record identifiers the user cannot access.

Conclusion

Search inside a business application is a set of decisions about filters, text matching and access control, and those decisions interact. Keep permissions in one enforced path, choose filters for known fields and full-text for discovery, and be explicit about index freshness. Rui Codex offers technical implementation support for custom search, data access and integrations across Belgium, the Netherlands and Luxembourg. If you want to review how search should work in your system, request a project consultation at the Rui Codex contact page or email info@ruicodex.com.

Frequently Asked Questions

Should search filter permissions before or after ranking?

Permissions should be applied before ranking, counting and pagination. Filtering after the database has returned a page leaves short pages, wrong totals and facet counts that can reveal restricted records. Applying the rule in the query keeps every part of the result consistent.

Is full-text search enough for an internal business application?

Full-text search is often enough for free-text discovery in one database. It is not a replacement for exact filters on identifiers, status or dates. Most internal screens need both, and the choice depends on the query patterns your users actually run.

How do you keep a search index in step with permission changes?

Treat a permission change as a data change that must reach the index. If access is copied into the index, update those copies in the same transaction where possible, or query permissions at search time. Measure the delay between the change and the visible result, and test it with a role that has just lost access.

When is a dedicated search engine worth the extra effort?

A dedicated search engine is worth considering when search must span several systems, when relevance needs detailed tuning, or when query load affects the main application. Before adopting one, confirm that permissions can be applied to every result and that the sync pipeline meets your freshness requirements. Otherwise the added service creates new leak paths.

Sources

Tags: business application search full-text search search filters access control API integration database indexing custom software search permissions

Need Help Implementing This?

Our team can help you put these insights into practice. From AI automation to custom software development, we build solutions that deliver real results.

Send a project request