How is your experience with the OutSystems Community?
Offline Keyword Search Demo

Offline Keyword Search Demo (ODC)

Stable version 0.1.0 (Compatible with ODC)
Uploaded on 15 Nov (2 days ago) by Michael Guzman
Offline Keyword Search Demo

Offline Keyword Search Demo (ODC)

Documentation
0.1.0

1. Prerequisites

  • The Offline Keyword Search library, installed from the Forge.
  • Mobile builds through MABS.
  • An iPhone, an iOS Simulator or an Android emulator.

2. Install

  1. In the ODC Portal, open Forge.
  2. Search for the Offline Keyword Search demo app.
  3. Click Install. The library installs with it if it is not already there.
  4. Open the app in the Portal and go to the Mobile distribution tab.
  5. Generate a package for iOS or Android.
  6. Install the package on your device.

3. Run the demo

The app has three tabs: Home (search), Procedures and Tools.

  1. Make sure the device is online.
  2. Open the Tools tab.
  3. Tap Sync Procedures. The app copies the 50 procedures into a local entity.
  4. Open the Procedures tab to check the records are there.
  5. On the Tools tab, tap Index Procedures.
  6. Tap Collection Info. It shows Exists ticked, Count 50, Unique Terms 572 and Avg Length 22.30.
  7. Turn on Airplane Mode.
  8. Open the Home tab and run the searches below.

4. Searches to try

Type a query, or tap one of the sample keywords, then tap Search. Each match shows its ID, Score, Metadata (title and code) and Terms, the number of query terms it matched.

  • E-217: Pump seal replacement (p14) comes first, at 5.14.
  • BT-3328: Conveyor belt tracking (p09) comes first.
  • MS-4471-C: Sump pump float test (p40) comes first.
  • red cylinder for putting out flames: no results. Keyword search matches words, not meaning.

The expected ranked results for 20 queries are in demo-expected.json.

5. How it is built

  • Seed data: the 50 procedures are a JSON resource. The server action GetSeedProcedures reads it with BinaryDataToText (Resources.seedproceduresv2_json.Content) and deserializes it into a List of SeedProcedure.
  • Local copy: SyncProcedures copies the list into the local entity LocalProcedure (Code, Title, Body, Category).
  • Index: Index Procedures calls UpsertMany with one KeywordItem per record: Id = Code, Text = Title + ". " + Body. Clear removes the collection.
  • Search: the Home tab calls Search and lists the matches.

The full build steps are in the ODC guide. The plugin is capacitor-offline-bm25 on npm.