NIP 50 Search #110

Closed
opened 2026-04-01 17:21:18 +00:00 by hodlbod · 1 comment
Owner

When searching rooms/spaces/everything, use NIP 50 with the appropriate relays (either the user's search relays, the default relays, or the space's relay).

When searching rooms/spaces/everything, use NIP 50 with the appropriate relays (either the user's search relays, the default relays, or the space's relay).
hodlbod added this to the Current milestone 2026-04-01 17:21:18 +00:00
hodlbod added the easy label 2026-04-01 17:21:18 +00:00
Contributor

Hi @hodlbod.

I've opened a PR for this — I replaced the local Fuse.js search with NIP-50 relay-side search in SpaceSearch.svelte.

Approach

The old implementation used createSearch (Fuse.js) over events already in the local repository, so it could only find messages that had been loaded into memory. I changed it to send a request() with the NIP-50 search filter field directly to relays.

Scope selection — I added three search scopes the user can toggle between:

  • Room — sends the search to the space's relay with #h tag filter
  • Space — sends the search to the space's relay (no room filter)
  • Everything — sends the search to the user's configured search relays from userSearchRelayList, falling back to DEFAULT_RELAYS if none are configured

Other details:

  • I added a 300ms debounce on input to avoid spamming relays
  • Used AbortController to cancel in-flight requests when a new search is triggered
  • Added search ID tracking to prevent stale results from overwriting newer ones
  • Included a relay status indicator so the user knows which relays are being queried
  • Results are deduplicated and sorted by time descending

Would appreciate a review when you get a chance. Thanks!

Hi @hodlbod. I've opened a PR for this — I replaced the local Fuse.js search with NIP-50 relay-side search in `SpaceSearch.svelte`. ### Approach The old implementation used `createSearch` (Fuse.js) over events already in the local repository, so it could only find messages that had been loaded into memory. I changed it to send a `request()` with the NIP-50 `search` filter field directly to relays. **Scope selection** — I added three search scopes the user can toggle between: - **Room** — sends the search to the space's relay with `#h` tag filter - **Space** — sends the search to the space's relay (no room filter) - **Everything** — sends the search to the user's configured search relays from `userSearchRelayList`, falling back to `DEFAULT_RELAYS` if none are configured **Other details:** - I added a 300ms debounce on input to avoid spamming relays - Used `AbortController` to cancel in-flight requests when a new search is triggered - Added search ID tracking to prevent stale results from overwriting newer ones - Included a relay status indicator so the user knows which relays are being queried - Results are deduplicated and sorted by time descending Would appreciate a review when you get a chance. Thanks!
bhavishy2801 was assigned by hodlbod 2026-04-02 17:36:13 +00:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: coracle/flotilla#110