-
Notifications
You must be signed in to change notification settings - Fork 6
Add Typesense plugin #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b8a1460
Typesense v1
clarkd 16a4f47
Apply suggestion from @clarkd
clarkd 91963d2
Merge branch 'main' into work/dc/typesense
clarkd 646b017
Typesense: clarify docs, enforce HTTPS, fix index
clarkd 7ce1148
Typesense: union multi_search & per_page validation
clarkd d9af675
Clarify per_page limit for Typesense plugin
clarkd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "steps": [ | ||
| { | ||
| "displayName": "Authenticate and check collection", | ||
| "dataStream": { "name": "searchValidation" }, | ||
| "required": true, | ||
| "error": "Could not query the collection. Check the Host URL, that the Search API Key is valid, and that it is authorised for the configured Collection.", | ||
| "success": "Connected successfully." | ||
| } | ||
| ] | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| { | ||
| "name": "documentSearch", | ||
| "displayName": "Document Search", | ||
| "description": "Documents from the configured collection matching a search query", | ||
| "tags": ["Search"], | ||
| "baseDataSourceName": "httpRequestUnscoped", | ||
| "config": { | ||
| "httpMethod": "get", | ||
| "endpointPath": "collections/{{dataSource.collection}}/documents/search", | ||
| "getArgs": [ | ||
| { "key": "q", "value": "{{q || '*'}}" }, | ||
| { "key": "query_by", "value": "{{query_by || null}}" }, | ||
| { "key": "filter_by", "value": "{{filter_by || null}}" }, | ||
| { "key": "sort_by", "value": "{{sort_by || null}}" }, | ||
| { "key": "per_page", "value": "{{per_page || 50}}" } | ||
| ], | ||
| "postRequestScript": "documentSearch.js" | ||
| }, | ||
| "matches": "none", | ||
| "ui": [ | ||
| { | ||
| "type": "text", | ||
| "name": "q", | ||
| "label": "Query (q)", | ||
| "defaultValue": "*" | ||
| }, | ||
| { | ||
| "type": "text", | ||
| "name": "query_by", | ||
| "label": "Query by fields", | ||
| "help": "Comma-separated fields to search; required unless q is *" | ||
| }, | ||
| { | ||
| "type": "text", | ||
| "name": "filter_by", | ||
| "label": "Filter by" | ||
| }, | ||
| { | ||
| "type": "text", | ||
| "name": "sort_by", | ||
| "label": "Sort by" | ||
| }, | ||
| { | ||
| "type": "number", | ||
| "name": "per_page", | ||
| "label": "Max results", | ||
| "defaultValue": 50, | ||
| "help": "This plugin supports up to 250 results per page", | ||
| "validation": { "min": 1, "max": 250 } | ||
| } | ||
| ], | ||
| "manualConfigApply": true, | ||
| "metadata": [ | ||
| { "name": "_relevance", "displayName": "Relevance", "shape": "number" }, | ||
| { "pattern": ".*" } | ||
| ], | ||
| "timeframes": false | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| { | ||
| "name": "multiSearch", | ||
| "displayName": "Multi Search", | ||
| "description": "Documents from a raw Typesense multi_search request, flattened across all sub-searches", | ||
| "tags": ["Search"], | ||
| "baseDataSourceName": "httpRequestUnscoped", | ||
| "config": { | ||
| "httpMethod": "post", | ||
| "endpointPath": "multi_search", | ||
| "getArgs": [{ "key": "collection", "value": "{{dataSource.collection}}" }], | ||
| "postBody": "{{query}}", | ||
| "postRequestScript": "multiSearch.js" | ||
| }, | ||
| "matches": "none", | ||
| "ui": [ | ||
| { | ||
| "type": "code", | ||
| "name": "query", | ||
| "label": "Query (JSON)", | ||
| "language": "json", | ||
| "defaultValue": { "searches": [{ "q": "*" }] }, | ||
| "help": "A Typesense multi_search body. Each search may set its own collection; otherwise the data source's configured collection is used. `\"union\": true` is supported, but merged rows have no Search # because they cannot be attributed to one sub-search." | ||
| } | ||
| ], | ||
| "manualConfigApply": true, | ||
| "metadata": [ | ||
| { "name": "_search", "displayName": "Search #", "shape": "number" }, | ||
| { "name": "_relevance", "displayName": "Relevance", "shape": "number" }, | ||
| { "pattern": ".*" } | ||
| ], | ||
| "timeframes": false | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| // dataStreams/scripts/documentSearch.js | ||
| // Typesense search response: { found, out_of, hits: [ { document: {...}, text_match, highlight, highlights } ] } | ||
| // Documents have an arbitrary, unknown schema per collection, so flatten each hit's | ||
| // document fields to top-level columns and add the relevance score. | ||
| result = (data.hits || []).map((h) => ({ ...h.document, _relevance: h.text_match })); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // dataStreams/scripts/multiSearch.js | ||
| // Federated multi_search response: { results: [ { found, hits: [ { document:{...}, text_match } ] } ] } | ||
| // A "union": true query instead merges everything into one set at the top level: { found, hits: [...] }. | ||
| // Flatten hits either way; only federated rows can be attributed to a numbered sub-search, | ||
| // so union rows leave _search empty. Our meta fields must win over document fields. | ||
| const federated = Array.isArray(data.results); | ||
| result = (federated ? data.results : [data]).flatMap((r, i) => | ||
| (r.hits || []).map((h) => ({ ...h.document, _search: federated ? i + 1 : null, _relevance: h.text_match }))); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // dataStreams/scripts/searchSummary.js | ||
| // Typesense search response root is an OBJECT: { found, out_of, search_time_ms, page, hits: [...] } | ||
| // Build a single summary row from the top-level counts, ignoring hits. | ||
| result = [{ | ||
| found: data.found, | ||
| out_of: data.out_of, | ||
| search_time_ms: data.search_time_ms, | ||
| page: data.page | ||
| }]; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| { | ||
| "name": "searchSummary", | ||
| "displayName": "Search Summary", | ||
| "description": "Match count, total document count and search time for a search query", | ||
| "tags": ["Search"], | ||
| "baseDataSourceName": "httpRequestUnscoped", | ||
| "config": { | ||
| "httpMethod": "get", | ||
| "endpointPath": "collections/{{dataSource.collection}}/documents/search", | ||
| "getArgs": [ | ||
| { "key": "q", "value": "{{q || '*'}}" }, | ||
| { "key": "query_by", "value": "{{query_by || null}}" }, | ||
| { "key": "filter_by", "value": "{{filter_by || null}}" }, | ||
| { "key": "per_page", "value": "0" } | ||
| ], | ||
| "postRequestScript": "searchSummary.js" | ||
| }, | ||
| "matches": "none", | ||
| "ui": [ | ||
| { | ||
| "type": "text", | ||
| "name": "q", | ||
| "label": "Query (q)", | ||
| "defaultValue": "*" | ||
| }, | ||
| { | ||
| "type": "text", | ||
| "name": "query_by", | ||
| "label": "Query by fields", | ||
| "help": "Comma-separated fields to search; required unless q is *" | ||
| }, | ||
| { | ||
| "type": "text", | ||
| "name": "filter_by", | ||
| "label": "Filter by" | ||
| } | ||
| ], | ||
| "metadata": [ | ||
| { "name": "found", "displayName": "Matching Documents", "shape": "number", "role": "value" }, | ||
| { "name": "out_of", "displayName": "Total Documents", "shape": "number" }, | ||
| { "name": "search_time_ms", "displayName": "Search Time", "shape": "milliseconds" }, | ||
| { "name": "page", "displayName": "Page", "shape": "number", "visible": false } | ||
| ], | ||
| "timeframes": false | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "name": "searchValidation", | ||
| "displayName": "Search Validation", | ||
| "description": "Up to one document from the configured collection", | ||
| "tags": ["Search"], | ||
| "baseDataSourceName": "httpRequestUnscoped", | ||
| "config": { | ||
| "httpMethod": "get", | ||
| "endpointPath": "collections/{{dataSource.collection}}/documents/search", | ||
| "getArgs": [ | ||
| { "key": "q", "value": "*" }, | ||
| { "key": "per_page", "value": "1" } | ||
| ], | ||
| "pathToData": "hits" | ||
| }, | ||
| "matches": "none", | ||
| "metadata": [{ "pattern": ".*" }], | ||
| "timeframes": false, | ||
| "visibility": { "type": "hidden" } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "items": [{ "name": "overviewDashboard", "type": "dashboard" }] | ||
| } |
139 changes: 139 additions & 0 deletions
139
plugins/Typesense/v1/defaultContent/overviewDashboard.dash.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| { | ||
| "name": "Overview", | ||
| "schemaVersion": "1.5", | ||
| "timeframe": "last24hours", | ||
| "dashboard": { | ||
| "_type": "layout/grid", | ||
| "columns": 4, | ||
| "version": 1, | ||
| "contents": [ | ||
| { | ||
| "i": "1e102028-7d08-4220-b038-9acab1d00e7a", | ||
| "x": 0, | ||
| "y": 0, | ||
| "w": 4, | ||
| "h": 1, | ||
| "moved": false, | ||
| "static": false, | ||
| "z": 0, | ||
| "config": { | ||
| "_type": "tile/text", | ||
| "title": "", | ||
| "description": "", | ||
| "visualisation": { | ||
| "config": { | ||
| "content": "Showing results from the configured Typesense collection.", | ||
| "fontSize": 14, | ||
| "align": "left", | ||
| "autoSize": true | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "i": "cc0e7c1c-a05f-47b8-8838-0597691526c3", | ||
| "x": 0, | ||
| "y": 1, | ||
| "w": 2, | ||
| "h": 2, | ||
| "moved": false, | ||
| "static": false, | ||
| "z": 0, | ||
| "config": { | ||
| "_type": "tile/data-stream", | ||
| "title": "Total Documents", | ||
| "description": "", | ||
| "activePluginConfigIds": ["{{configId}}"], | ||
| "dataStream": { | ||
| "id": "{{dataStreams.[searchSummary]}}", | ||
| "name": "searchSummary", | ||
| "pluginConfigId": "{{configId}}", | ||
| "dataSourceConfig": { | ||
| "q": "*" | ||
| } | ||
| }, | ||
| "timeframe": "none", | ||
| "visualisation": { | ||
| "type": "data-stream-scalar", | ||
| "config": { | ||
| "data-stream-scalar": { | ||
| "value": "found", | ||
| "comparisonColumn": "none", | ||
| "label": "Matching Documents" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "i": "693f6164-c6e5-4906-b77b-4c1da5222915", | ||
| "x": 2, | ||
| "y": 1, | ||
| "w": 2, | ||
| "h": 2, | ||
| "moved": false, | ||
| "static": false, | ||
| "z": 0, | ||
| "config": { | ||
| "_type": "tile/data-stream", | ||
| "title": "Search Time", | ||
| "description": "", | ||
| "activePluginConfigIds": ["{{configId}}"], | ||
| "dataStream": { | ||
| "id": "{{dataStreams.[searchSummary]}}", | ||
| "name": "searchSummary", | ||
| "pluginConfigId": "{{configId}}", | ||
| "dataSourceConfig": { | ||
| "q": "*" | ||
| } | ||
| }, | ||
| "timeframe": "none", | ||
| "visualisation": { | ||
| "type": "data-stream-scalar", | ||
| "config": { | ||
| "data-stream-scalar": { | ||
| "value": "search_time_ms", | ||
| "comparisonColumn": "none", | ||
| "label": "Search Time" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| { | ||
| "i": "8b4d3946-efa0-4180-bc02-5a20ed445cef", | ||
| "x": 0, | ||
| "y": 3, | ||
| "w": 4, | ||
| "h": 6, | ||
| "moved": false, | ||
| "static": false, | ||
| "z": 0, | ||
| "config": { | ||
| "_type": "tile/data-stream", | ||
| "title": "Documents", | ||
| "description": "", | ||
| "activePluginConfigIds": ["{{configId}}"], | ||
| "dataStream": { | ||
| "id": "{{dataStreams.[documentSearch]}}", | ||
| "name": "documentSearch", | ||
| "pluginConfigId": "{{configId}}", | ||
| "dataSourceConfig": { | ||
| "q": "*", | ||
| "per_page": 25 | ||
| } | ||
| }, | ||
| "timeframe": "none", | ||
| "visualisation": { | ||
| "type": "data-stream-table", | ||
| "config": { | ||
| "data-stream-table": { | ||
| "transpose": false | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| [] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.