Last active
August 16, 2022 11:44
-
-
Save hraftery/ac00f8bcbba0a981e351a3c03ea2e09d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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: '[email protected]' }, 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: '[email protected]' }, 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