Complete documentation of how search works on q.nostrwat.ch.

Nostr events viewer with a built-in search engine.

q.nostrwat.ch — Full Search Specifications

Complete documentation of how search works on q.nostrwat.ch.


Overview

q.nostrwat.ch is a Nostr events viewer with a built-in search engine. Search works by:

  1. Parsing the query into structured parts (phrases, words, exclusions, tags, operators).
  2. Building a query plan: several parallel “lanes” of relay requests, because Nostr relays disagree about which filters they support.
  3. Running all lanes in parallel, plus an instant scan of the local IndexedDB cache.
  4. Verifying every result client-side in JavaScript and scoring it for relevance, so relays that ignore parts of a filter never widen the results.

A search runs as several parallel lanes:

Lane What it does
nip50 NIP-50 text search on the dedicated search relays
nip50-author NIP-50 text + authors filter (some relays handle the combination, many do not)
author-feed Plain NIP-01 authors filter on the default relays + the author’s NIP-65 outbox relays; text is checked in JS
tags Plain NIP-01 #t filter on default + search relays; text is checked in JS
url-r / url-i NIP-01 #r / #i tag filters for full URLs
local Instant scan of the IndexedDB cache (kinds, authors, since/until, limit 40)

Query Language (typed in the search box)

Everything is typed in one box. Operators are case-insensitive for detection (the operator name is lowercased before matching).

Operator Syntax Meaning
Exact phrase "bitcoin whitepaper" The phrase must appear verbatim. Phrases are not sent to relays (engines disagree about quotes); they are enforced client-side with substring matching on normalized text. Each matching phrase adds 50 to the relevance score.
Words bitcoin Free words. Matched client-side against event text and tag values.
Exclusion -spam An event is rejected if the excluded term appears in text or tag values. A negative number (like -5) is treated as a word, not an exclusion.
Hashtag #coffee 1–64 letters, numbers or underscores. Sent as a #t tag filter where supported and verified client-side (tag value must equal the tag, or text must contain #tag).
Author from:npub1…, from:<hex>, from:alice@example.com, or the alias by: Restricts to one author. Accepts npub, nprofile, a 64-char hex key, or a NIP-05 address (resolved through NIP-05 before planning).
Kind kind:1,30023 Overrides the content-type pills. Up to 10 comma-separated integers between 0 and 65535, deduplicated.
Since since:7d Lower time bound. Formats: Nh (hours), Nd (days), Nw (weeks), Nm (months, 30 days), or YYYY-MM-DD (UTC, start of day). Invalid values produce an error message.
Until until:2025-12-31 Upper time bound. YYYY-MM-DD means end of day (23:59:59 UTC); relative formats also work.
Has media has:media (alias is:media) Event must be a media kind (20, 21, 22, 34235, 34236), or contain a media file URL (jpg/png/gif/webp/avif/mp4/webm/mov/m4v/mp3/ogg/wav), or have an imeta tag.
Has link has:link (alias is:link) Event must contain a URL, or have an r tag.

Notes:

  • Text matching is accent-insensitive: both query and event text are lowercased, Unicode NFD-normalized and stripped of combining marks.
  • Multiple terms are combined as follows: in relay-less lanes every word must be present (all mode); in NIP-50 lanes at least one word must hit (any mode, because NIP-50 engines stem/fuzz).
  • URLs in the query are additionally used to look up #r/#i link tags (up to the first 2 URLs).

Validation errors

The planner returns one error at a time:

  • Unrecognized since/until value → suggests 7d, 24h, 2w, 3m or YYYY-MM-DD.
  • Custom kind → up to 10 numbers between 0 and 65535, comma-separated.
  • Author → must be nostr:npub1…, nostr:nprofile1…, 64-char hex, or a resolvable NIP-05 address.
  • Empty query → “Type something to search for, or add an author in the filters.”
  • has:media / has:link alone → need a word, #tag or author to search for.

Minimum input: a term of at least 2 characters, or an author filter.


Content Types (pills)

The pills select kinds. A custom kind: operator overrides the selected pill.

Main pills

Pill Kinds Meaning
All 0, 1, 30023 Profiles, notes, articles
Notes 1 Notes
People 0 Names, NIP-05, bios
Articles 30023 Long-form articles
Media 20, 21, 22, 34235, 34236 Pictures, videos, shorts
Market 30402, 30018 Classifieds / app-specific market items

“More” menu

Pill Kinds Meaning
Highlights 9802 Highlights
Communities 34550 Community definitions
Live 30311 Live events
Events 31922, 31923 Calendar / meetups
Wiki 30818 Wiki articles
Audio 31337 Audio / tracks

Tabs other than All / Notes / People / Articles show a notice: “Not every search relay indexes this kind, expect fewer results.”


Filter Drawer (advanced filters)

Filter Values Behavior
Author nostr:npub1… or hex Restricts results to one author (same as from:).
Custom kind e.g. 30818 or 1,30023 Overrides the pill. Max 10 kinds, 0–65535.
Time window Any time, Past 24 hours, Past week, Past month Combined with since:/until: (the stricter bound wins for since).
Language Any, en, es, pt, fr, de, it, ja, zh, ru, ko, nl, ar, hi, tr Sent as language:xx inside the NIP-50 search string; applies to text searches only.
NIP-05 domain e.g. example.com Sent as domain:example.com in the NIP-50 search string.
Sort Newest first, Best match See ranking below.
Include spam checkbox Adds include:spam to the NIP-50 search string.

Language, domain and spam apply only to NIP-50 text searches.


Time and Relay Behavior

Time windows

Relative ranges: any = no bound, day = 86400s, week = 7 days, month = 30 days, measured from “now”. An operator since: replaces (stricter of) the drawer range; until: is always applied.

Relays

  • Search relays (defaults: relay.poster.place, relay.cyberguy.fyi, x.kojira.io) are used for NIP-50 text search lanes. The list is user-configurable (from your kind 10007, a local list, or defaults) via the ⚡ relay pill.
  • Default relays (6) are used for hashtag and author-only searches, link-tag lanes, and NIP-65 outbox lookups.
  • Author outbox relays (NIP-65, kind 10002): for author lanes, the app fetches the author’s write relays (up to 4, excluding the defaults) and queries them too, with a 1.2 s wait before results are shown (the lookup keeps running for later pages).

Deduplication

Replaceable/addressable events are deduplicated by key:

  • Kind 0, 3, and 10000–19999: only the newest version per kind:pubkey.
  • Kinds 30000–39999: only the newest version per kind:pubkey:d-tag.

Client-Side Verification and Ranking

Every candidate event is re-checked in JS before being shown, so relays that ignore filter parts can’t widen results (SearchFilterOk verifies kinds, authors, since/until and #t/#r/#i tags).

Rejection rules (SearchMatchAndScore returns -1)

  • An excluded term appears in text or tags.
  • has:media not satisfied (media kind, media URL in content, or imeta tag).
  • has:link not satisfied (URL in content or r tag).
  • Any quoted phrase missing.
  • No word hit in all mode, or zero hits in any mode.
  • A #tag present in the query but no tag hit when the lane requires tags.

Scoring (higher = more relevant)

Signal Points
Each matched exact phrase +50
Each word matched in text +20
Each word matched in a tag value +10
Each query tag matching an exact t tag +25
Each query tag matching #tag in text +15
Article (kind 30023) +15
Profile (kind 0) +10
Content length 41–1999 chars +5
Recency up to +8, decaying over ~8 months
- Excluded/rejected events: -1 (removed)

Profiles are matched on their parsed metadata (name, display_name, displayName, nip05, about, lud16, website), not on the raw JSON string.

“Best match” sort uses this score; “Newest first” sorts by created_at.


Query Planning Rules (lane selection)

Given a parsed query, the plan is:

  • Text present:
    • Always: nip50 lane on search relays (search string = words + phrases + #tags + modifiers like language:, domain:, include:spam).
    • If an author is set: add nip50-author lane (search relays, text + authors) and an author-feed lane (default relays + outbox relays, limit × 5, #t filter if tags present).
    • Else if tags present: add a tags lane on all relays (default + search), text verified in JS.
    • For each URL (max 2): url-r and url-i lanes on default relays.
  • No text, author present: author-feed lane only (limit × 5 if the query uses has:media/has:link/exclusions), default + outbox relays.
  • No text, tags only: tags lane on all relays.
  • Only has:media / has:link: error (needs a word, tag or author).

Local cache scan always runs alongside (kinds + authors + since/until, limit 40).

Non-basic tabs with text searches are flagged “niche” for a reduced-results warning.


Submit Behavior and URLs

Direct navigation

  • A Nostr identifier (npub1…, nprofile1…, note1…, nevent1…, naddr1…, optionally with a nostr: prefix) goes straight to its page: q.nostrwat.ch/<identifier>.
  • A bare NIP-05 address (alice@example.com) is resolved through NIP-05 (fetched from https://example.com/.well-known/nostr.json?name=alice, 5 s timeout):
    • Resolved → navigate to the author’s npub page.
    • Not resolved → fall back to a people search for the name with domain:example.com set.

URL structure

  • The search term stays in the path: q.nostrwat.ch/<term> (URI-encoded; # and ? always percent-encoded).

  • All filters live in the URL hash so the server never sees them:

    #tab=articles&kind=1,30023&author=npub1…&range=week&lang=en&domain=example.com&spam=1&sort=best

    Only non-default values are written.

Result summary

The UI shows a one-line plan summary, e.g. "latte #coffee" · by npub1abc… · Articles · past week · language en · 9 relays.


Quick Reference Card

Search box syntax
  "exact phrase"      verbatim, verified client-side
  word                free word (all must match without a NIP-50 lane)
  -word               exclude
  #tag                hashtag (t tag)
  from:npub1…         also: by:npub1…, from:<hex>, from:alice@example.com
  kind:1,30023        overrides pills, max 10 kinds, 0–65535
  since:7d            7d | 24h | 2w | 3m | YYYY-MM-DD
  until:2025-12-31    end of day (UTC)
  has:media           is:media also works
  has:link            is:link also works

Pills
  All 0,1,30023 · Notes 1 · People 0 · Articles 30023
  Media 20,21,22,34235,34236 · Market 30402,30018
  More: Highlights 9802 · Communities 34550 · Live 30311
        Events 31922,31923 · Wiki 30818 · Audio 31337

Filters (drawer / URL hash)
  tab, kind, author, range (any|day|week|month), lang,
  domain, spam=1, sort (new|best)

Relays
  Text search → NIP-50 search relays (default: relay.poster.place,
  relay.cyberguy.fyi, x.kojira.io)
  Tags and author-only → default relays (6) + author's NIP-65 outbox
  Results always re-verified and ranked in the browser

Write a comment