~/lab/next
~/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
| title | type | author | views | published |
|---|
how it was read
~/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
- Rules. PHP rules read types, names, numbers, dates, negation and sort words. This step needs no network and no key.
- 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.
- Check. Every chip is checked against the list of fields the developer allowed. A chip for any other field is dropped.
- Query. The chips that pass become one database query. The words left over become a text search.
- 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
Write to me about the problem you want to fix.
- emailEmail contact@meirdick.com
- linkedinLinkedIn in/mdick
- githubGitHub meirdick
- substackSubstack aistrategyconsultant
- rssRSS /rss.xml
~/mail/new