Skip to content

Instantly share code, notes, and snippets.

@hraftery
Last active August 16, 2022 11:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hraftery/ac00f8bcbba0a981e351a3c03ea2e09d to your computer and use it in GitHub Desktop.
Save hraftery/ac00f8bcbba0a981e351a3c03ea2e09d to your computer and use it in GitHub Desktop.
/*
* Perform a basic text search of all (internally generated) chat messages in Jellyfish, like Omnisearch used to do for Flowdock.
*
* Usage:
* 1. Change `theSearchPattern` to the string you're searching for
* 2. Enter line in the Console in the Developer Tools in the browser, after logging into Jellyfish.
* 3. The first 20 results will appear in the console. To see more, press up and return to re-enter the last command.
*
* In case it wasn't clear, this is a terrible hack and not expected to be fit for anything beyond amusement.
*/
theSearchPattern = "enter search string here"; //technically this is a regular expression, but a literal string works too.
//schema = { type: 'object', properties: { type: { const: 'message@1.0.0' }, data: { not: { required: [ "origin" ] }, properties: { payload: { properties: { message: { pattern: theSearchPattern } } } } } } };
//Use the text search indexes instead of regex, which amongst other things allow fuzzy matching. Kudos to Lucian for this tip.
schema = { type: 'object', properties: { type: { const: 'message@1.0.0' }, data: { not: { required: [ "origin" ] }, properties: { payload: { properties: { message: { fullTextSearch: { term: theSearchPattern } } } } } } } };
cursor = sdk.getCursor(schema);
cursor.nextPage().then((data) => { data.forEach( (item) => { console.log({slug: item.slug, date: item.created_at, message: item.data.payload.message}); } ) } );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment