Skip to content
Meir Dick
anon@meirdick
More in Lab
~/lab
Where next
~/lab/next
Search chips
~/lab/search-chips

Search chips

Type a search as a sentence. A Laravel package turns it into typed filters and shows each one as a chip you can remove.

showing
    filters
    type
    views
    published
    featured
    titletypeauthorviewspublished
    About this demo
    ~/lab/search-chips/notes

    What

    The demo from auto-search-chips, a Laravel package I built. A user types a search as a plain sentence. The package turns it into typed filters on a database model and shows each filter as a chip under the box. The underlined words show which part of the sentence became which chip.

    How

    model
    Clairic + a rules engine
    id
    @cf/cloudflare/clairic
    runs on
    the package's demo app in its own Cloudflare Container; Clairic on Workers AI
    costs
    about $0.0001 for a sentence you type; the seven examples are saved and free
    1. Rules. PHP rules read types, names, numbers, dates, negation and sort words. This step needs no network and no key.
    2. Clairic. The extraction model reads the words the rules did not explain. It can add a chip. It cannot change a chip from the rules.
    3. Check. Every chip is checked against the list of fields the developer allowed. A chip for any other field is dropped.
    4. Query. The chips that pass become one database query. The words left over become a text search.
    5. Here. The package runs in a Cloudflare Container with no Internet access and no API token. Its one way out is a Worker that passes the Clairic call to Workers AI.

    Why

    A filter form makes the user learn the form. A chat box hides what it did. Chips are in between: the user writes what they want, then sees how it was read and can remove a wrong part. A small extraction model is enough for this, because the rules do most of the work.

    Try

    • "shows not by Grace": "shows" is a synonym for podcast, and "not by" excludes an author.
    • "more then 100 views": the typo "then" is read as "than". "garden" matches no field, so it becomes a text search. Remove that chip and five posts appear.
    • "videos lovelace posted": no "by" in front of the name, so the rules miss it. Clairic adds the author chip. Open "how it was read" to see the call.
    • How it was read: under the results, each step the package took: the rules, the Clairic call with what was sent and what came back, the check, and the SQL.
    • "since january": a month with no day means the first day of that month.
    • The filter panel: it shows the same chips as form controls. Type a sentence and watch the controls fill in. Change a control and a chip changes.
    • Your own sentence: type it and press Enter. Then remove a chip: the package checks the chips that remain and runs the query again.

    Limits

    • The first search after a quiet time starts the container. That takes about 15 seconds. After that a search takes about a second.
    • The example buttons replay parses saved in November 2026, with no network. Press Enter on one to run it live.
    • The data is 60 made-up posts by four authors. A sentence about a field the posts do not have becomes a text search.
    • The demo has a limit of 20 searches a minute for each visitor and 3,000 a day in total.
    • To run it for real, install it: quickstart, source.
    Contact
    ~/contact

    Write to me about the problem you want to fix.

    Write to me
    ~/mail/new
    Ctrl+Enter sends.
    1 – 5 switch workspace n b where next: the next step, or back Enter go to the menu ↑ ↓ Enter in the menu: move, open space / Ctrl K launcher: essays, builds, eras, themes, commands h l j k move focus: h l between columns, j k within one H L resize: move the split left or right J K resize: grow or shrink the focused side window f fullscreen the focused window w or q close the window under the mouse (reopen it from the launcher) t pick a theme m or c contact: write to me Esc leave a text box, the menu, fullscreen or a dialog Ctrl Enter send the message in the mail window ? this list