Elasticsearch (ES) is a server-side search engine managed by the platform administrator. From a form designer's perspective, ES is just another data source — you access it using the same mechanisms as any other remote or local data.
Real-time search with search-api()
Point search-api() at the ES _search endpoint using POST method. In the appearance column:
search-api('POST',
'https://es.example.com/my_index/_search',
'{"query":{"match":{"name":"%__input__%"}},"size":20}',
'_id',
'##_source.name## — ##_source.district##',
'$.hits.hits',
'es_result')Key points:
data_pathmust be$.hits.hits— each hit in the array becomes one result itemdisplay_templateuses##_source.fieldname##to access nested source fieldsvalue_columnis typically_idor a field inside_source- After selection, read any field with
pulldata('es_result', '_source.district'),pulldata('es_result', '_source.province'), etc.
See Dynamic Search for the full search-api() parameter reference.
When to use: Data changes frequently and the device has reliable connectivity.
Offline access with dataSetting.csv
Use dataSetting.csv to download an ES data export as a SQLite file at form open time. The server exports the ES index as a SQLite file with a single externalData table. Once on the device, query it with rawquery like any other local database.
dataSetting.csv entry for an ES export:
filepath,service_url,option,frequency,primary_key,where,dynamic_part
resources/familyMedia/FORM/staff.db,./api/es/export?index=hr_staff,overwrite,3600,,,Then in the form's appearance column:
search-autocomplete-noedit-v2('rawquery',
concat(${family_path}, '/staff.db::externalData'),
'[name]', 'id',
'SELECT name, id FROM externalData WHERE marked_as_deleted != 1')See Data Settings and Local Database Search for full reference.
When to use: Data changes daily or weekly and offline access is required.
Choosing the right approach
| Situation | Use |
|---|---|
| Data changes frequently, device is always online | search-api() → ES _search |
| Data changes daily / weekly, offline needed | dataSetting.csv + rawquery |
| Data is static | Bundled CSV in family media |
Security note
The ES cluster uses HTTP Basic Auth managed server-side — credentials are never sent to devices. When search-api() queries ES directly from the device, the request is sent without authentication headers.
Do not expose sensitive personal data in an ES index queried directly via search-api(). For sensitive data, use the offline mode (dataSetting.csv) — the server handles the authenticated ES export and devices never communicate with ES directly.