PRACTICAL FIELD GUIDE

Contains search with a LIKE filter: how it matches

A contains-style filter is different from a full-text search engine. Test its matching behavior and workload before promising ranked search or typo tolerance.

MCPBackend editorial team · · Examples are illustrative

The short answer

A like filter is a substring match, not a search engine. ?title[like]=report runs SQLite's LIKE with the value wrapped as %report%, so it returns every row whose title contains "report" anywhere: "Q3 report", "Reporting tools" and "unreported" all match. Results come back in table order (or your sort), not by relevance.

Three details trip people up: the match ignores case only for ASCII letters, a % or _ typed by the user acts as a wildcard, and a leading wildcard means the database reads every row in the table to answer the query.

How the match behaves, case by case

  • Case: "Report", "REPORT" and "report" match each other. Letters outside ASCII (é, ü, Cyrillic, Greek) compare case-sensitively, so "École" does not match "école".
  • Wildcards: the value is not escaped. Searching for 50% matches "50" followed by anything, and an underscore matches any single character. Strip or reject % and _ in user input if they should be literal.
  • Whole words: there is no word boundary. "cat" matches "category" and "concatenate".
  • Typos and plurals: no fuzzy matching or stemming. "recipie" will not find "recipe", and "mice" will not find "mouse".
  • Several words: "blue shirt" is matched as one phrase, in that order. To require both words anywhere, filter on the column you need and narrow results on the client, or store a normalised search column.
  • Empty value: title[like]= matches every row where title is not NULL.

A search box that does not hammer the API

Every request counts toward the project's monthly API request cap, so a filter-as-you-type box should wait for a pause and skip very short input.

let timer;
input.addEventListener("input", () => {
  clearTimeout(timer);
  const q = input.value.trim().replace(/[%_]/g, ""); // keep wildcards literal-free
  if (q.length < 2) return render([]);
  timer = setTimeout(async () => {
    const params = new URLSearchParams({ "title[like]": q, limit: "20", sort: "title" });
    const res = await fetch(`${base}/v1/${projectId}/db/articles?${params}`, {
      headers: { authorization: `Bearer ${token}` },
    });
    render(res.ok ? (await res.json()).data : []);
  }, 300);
});

When a LIKE filter is not enough

Contains search is fine for an admin list, a few thousand product names or a personal notes app. Move to a dedicated search index when you need relevance ranking, typo tolerance, stemming, search across several fields at once, or fast results on a large table. Keep MCPBackend as the source of truth and sync changes into the index, for example from a row-change webhook.

Put it into practice

  1. Choose the searchable field and inspect the supported like filter semantics.
  2. Test case, punctuation and special characters with representative input.
  3. Measure behavior on realistic data and consider a separate search service if the product needs richer retrieval.

What this looks like

ILLUSTRATIVE EXAMPLE

A title contains search finds matching substrings, but it does not automatically rank documents by relevance or correct misspellings.

A boundary to keep clear

Do not present a simple filter as a full search platform. Its query cost and matching semantics still need review.

MCPBackend context

Use get_project_api or the dashboard's generated OpenAPI contract for your project's exact data-plane routes. Machine keys and end-user tokens have different access models. Treat error status and JSON code together, keep credentials out of URLs, and test against disposable records before changing real data.

Take the next step

Inspect the current project contract, try the change with disposable data, and verify the result through the same credentials your app will use. Record the expected response and one denied-access case before release.

Frequently asked questions

Is the like filter case-insensitive?

For ASCII letters, yes: Report and report match. Accented and other non-ASCII letters compare case-sensitively.

How do I search for a literal % or _?

You cannot escape them through the filter, because the value is passed to LIKE as-is inside %...%. Remove them from the search text, or store a cleaned copy of the column for searching.

Does the like filter use an index?

Not usefully. The pattern starts with a wildcard, so SQLite reads every row in the table. Combine it with an equality filter on an indexed column where you can, and keep the table size in mind.

Can I rank results by relevance?

No. Rows come back in table order or by the column you pass in sort. For ranked or fuzzy search, use a separate search service fed from your data.

Sources and further reading

These references explain the underlying protocols and design principles. For supported MCPBackend operations and exact request shapes, inspect your project’s generated API contract.