wappler-wap-lastic
v1.2.10
Published
Wappler Server Connect extension for weighted tokenised search with configurable columns and GET bindings
Downloads
1,182
Maintainers
Readme
Wap-Lastic
Weighted, tokenised search for Wappler Server Connect: score and rank database results in the UI, without giant hand-built SQL actions.
Think of it as elastic-style search for Wappler (tokenised keywords, per-field weights, relevance ranking): the behaviour you want from “elastic” search, built as a native Server Connect step. It does not connect to Elasticsearch or Elastic Cloud; it works on your existing query results or generated MySQL SQL.
Built by Mr Cheese · Wappler extensions & custom modules
Why this exists
In Wappler, “good search” often means enormous Server Connect actions: keyword CTEs, many CASE expressions per column, weights, exclusions, boost columns, sort modes, and pagination, all duplicated when you add a field or change a table.
Wap-Lastic replaces that with one step:
- Run your normal database query (your connection, filters, joins).
- Add Wap-Lastic Weighted Search and pick columns + weights in the UI.
- Return ranked rows with
relevance_scoreandboosted_score, ready for repeats and data bindings.
Typical problem it solves: a user searches fishing caldas but the stored text is Fishing shop caldas da rainha. Exact LIKE on the whole string fails. Wap-Lastic tokenises the search phrase, matches per column, applies weights, and sorts by relevance, all configured visually, not with another 400-line JSON action.
Features
| Capability | Description |
|------------|-------------|
| Query-first workflow | Bind the prior query step; no second connection field in default mode |
| Weighted columns | Data picker per column + numeric weight + optional “exclude if also matched in…” |
| Any search input | Bind any $_GET (or expression) for terms, limit, and offset |
| Output columns | Choose which fields go to the API and page; empty = all query columns |
| Scores on every row | relevance_score and boosted_score always included |
| Boost column | Optional numeric field from your query (e.g. priority, search score) to push listings higher |
| Array or object API | Default array output (works like a query step in App Connect) |
| SQL generate mode | Advanced: build weighted MySQL SQL for very large datasets |
No project-specific tables or connections are baked in. Configure everything in your own API after install.
Requirements
- Wappler project with Server Connect (Node)
- Query mode (recommended): any database query step that returns an array of rows
- SQL mode (advanced): MySQL
Installation
Official Wappler guide: How To Install Custom Wappler Extensions.
| Path | |
|------|--|
| npm | Wappler Project Settings → Extensions (wappler-wap-lastic) |
| Git | Extension Installer or manual copy below |
Git manual copy installs into extensions/ and lib/modules/.
Git install — Extension Installer (recommended)
This repo ships wappler-install.json at the root. Use the Mr Cheese Extension Installer — select Wap-Lastic, enable Use wappler-install.json from the repository, and run the generated copy commands locally.
Manual install
Run from your Wappler project root (the folder that contains package.json). Skip git clone if you already have this repo cloned alongside your project.
git clone https://github.com/MrCheeseGit/Wap-Lastic-Wappler-Elastic-Search-Extension.git ../Wap-Lastic-Wappler-Elastic-Search-Extension
cp ../Wap-Lastic-Wappler-Elastic-Search-Extension/server_connect/modules/waplastic.hjson extensions/server_connect/modules/
cp ../Wap-Lastic-Wappler-Elastic-Search-Extension/server_connect/modules/waplastic.js lib/modules/Quit Wappler completely and restart after installing or updating.
The action appears under Mr Cheese → Wap-Lastic Weighted Search.
npm install (Wappler Project Settings)
- Wappler → Project Settings → Extensions → Add →
wappler-wap-lastic - From your project root:
npm install - Quit Wappler completely and reopen your project.
Local file: development (optional)
"devDependencies": {
"wappler-wap-lastic": "file:../path/to/this-extension"
}After you change extension source, run npm install again, then Project Updater if needed, and restart Wappler.
Quick start
Database Query (SELECT) → Wap-Lastic Weighted Search → Page repeat / API output- Add a Database Query step (SELECT) with your connection, table, and filters.
- Add Wap-Lastic Weighted Search below it.
- Mode: From query step (default).
- Query results: data picker → your query (e.g.
{{productsQuery}}). - Search terms: e.g.
{{$_GET.q}}. - Weighted columns: add rows, pick fields, set weights (e.g.
name= 100,description= 50). - (Optional) Boost column: pick a numeric column from your query if you already store a priority or score (see below).
- Output columns: pick fields for the response, or leave empty for all columns.
- Enable Output, run the API once, save (refreshes step
metafor the page picker). - On the page, bind the Wap-Lastic step (e.g.
{{searchResults}}), not the raw query step.
See examples/generic-weighted-search.json for a full generic template.
Configuration reference
Search columns
| Column | Description | |--------|-------------| | Column | Field from your query (data picker) | | Weight | Higher = ranks higher when the keyword matches | | Exclude if also in | Comma-separated fields; skip this column’s score if the keyword also matches there |
Boost column (your own score / priority field)
If your query already returns a numeric score column (for example priority, searchPriority, rank, or any value you use to promote listings), Wap-Lastic can use it on top of keyword relevance.
In the Scoring group:
| Setting | Description |
|---------|-------------|
| Boost column | Data picker → numeric field from your query step (leave empty to rank by relevance only) |
| Boost multiplier | How strongly that column affects sort order (default 50) |
How it works
Wap-Lastic calculates
relevance_scorefrom matched search keywords and your weighted columns.If a boost column is set, it computes
boosted_score:boosted_score = relevance_score + (boostColumnValue - 1) * boostMultiplierDefault sort uses
boosted_score, so rows with a higher value in your score column rise when relevance is similar.
Example: priority = 2 and multiplier = 50 adds 50 points to relevance_score. A featured product with a strong priority value can outrank a slightly better text match with low priority.
Include the boost field in your database query SELECT. You do not need a separate weight row in Weighted columns for the same field unless you also want keyword matching on that column.
See examples/generic-weighted-search.json (boostColumn: priority, boostMultiplier: 50).
Output columns
| Column | Description |
|--------|-------------|
| Column | Field to include in the response (picker may save {{yourQuery[0].field}}; the module extracts field) |
| Type | Optional; helps schema / picker |
Leave Output columns empty to return every column from the query plus both score fields.
Page data picker
Wappler uses the step meta array in your API JSON for frontend bindings.
- Configure output columns (or leave empty).
- Run the API with Output enabled, then save.
- Bind
{{yourWaplasticStep}}on the page.
If only scores appear in the picker, remove stale meta on the Wap-Lastic step, run the API again, and save.
Response shape
Array (default), best for repeats:
[
{
"id": 1,
"name": "Fishing shop",
"relevance_score": 100,
"boosted_score": 150
}
]Object, when you need { success, data, total }:
{
"success": true,
"data": [{ "id": 1, "name": "Fishing shop", "relevance_score": 100, "boosted_score": 150 }],
"total": 42
}SQL generate mode (advanced)
For very large tables:
- Set Mode to SQL generate.
- Set connection, SELECT / FROM / WHERE fragments, and SQL parameters.
- Use only when query-mode scoring is not suitable.
Project layout
Wap-Lastic-Extension/
├── waplastic.js # Server Connect module
├── waplastic.hjson # Wappler UI definition
├── package.json
├── README.md # You are here
├── extension_summary.md # Short overview
├── CHANGELOG.md
├── LICENSE
└── examples/
├── README.md
└── generic-weighted-search.jsonLimitations (v1)
- Query mode scores rows returned by your query (apply filters in the query step).
- SQL generate mode: MySQL only.
- No fuzzy / typo tolerance yet.
Documentation
- Extension summary: problem, approach, and benefits in brief
- Examples
- Changelog
Compatibility
Standalone extension. For shared patterns (Redirect-IT step order, PuSH-IT, optional pairs), see Mr Cheese extension docs.
License
Mr Cheese Extension License v1.0 — see LICENSE. © Mr Cheese
mrcheese.co.uk · Wappler Server Connect extensions
