diff options
| author | Jon Staab <jstaab@protonmail.com> | 2023-05-12 05:10:45 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-12 05:10:45 -0700 |
| commit | e5302f84c74cf42d878a3ed18257a16bc0d3b748 (patch) | |
| tree | b1a3ad9c0317bf7c38f34c500559b66ff7c0a22d /50.md | |
| parent | 1c728516dfdc7508ce27eda222bde78466e3457d (diff) | |
| parent | 4208652dc7a39c63c39559b13c656ec30400fcba (diff) | |
Merge branch 'master' into patch-1
Diffstat (limited to '50.md')
| -rw-r--r-- | 50.md | 49 |
1 files changed, 49 insertions, 0 deletions
| @@ -0,0 +1,49 @@ | |||
| 1 | NIP-50 | ||
| 2 | ====== | ||
| 3 | |||
| 4 | Search Capability | ||
| 5 | ----------------- | ||
| 6 | |||
| 7 | `draft` `optional` `author:brugeman` `author:mikedilger` `author:fiatjaf` | ||
| 8 | |||
| 9 | ## Abstract | ||
| 10 | |||
| 11 | Many Nostr use cases require some form of general search feature, in addition to structured queries by tags or ids. | ||
| 12 | Specifics of the search algorithms will differ between event kinds, this NIP only describes a general | ||
| 13 | extensible framework for performing such queries. | ||
| 14 | |||
| 15 | ## `search` filter field | ||
| 16 | |||
| 17 | A new `search` field is introduced for `REQ` messages from clients: | ||
| 18 | ```json | ||
| 19 | { | ||
| 20 | ... | ||
| 21 | "search": <string> | ||
| 22 | } | ||
| 23 | ``` | ||
| 24 | `search` field is a string describing a query in a human-readable form, i.e. "best nostr apps". | ||
| 25 | Relays SHOULD interpret the query to the best of their ability and return events that match it. | ||
| 26 | Relays SHOULD perform matching against `content` event field, and MAY perform | ||
| 27 | matching against other fields if that makes sense in the context of a specific kind. | ||
| 28 | |||
| 29 | A query string may contain `key:value` pairs (two words separated by colon), these are extensions, relays SHOULD ignore | ||
| 30 | extensions they don't support. | ||
| 31 | |||
| 32 | Clients may specify several search filters, i.e. `["REQ", "", { "search": "orange" }, { "kinds": [1, 2], "search": "purple" }]`. Clients may | ||
| 33 | include `kinds`, `ids` and other filter field to restrict the search results to particular event kinds. | ||
| 34 | |||
| 35 | Clients SHOULD use the supported_nips field to learn if a relay supports `search` filter. Clients MAY send `search` | ||
| 36 | filter queries to any relay, if they are prepared to filter out extraneous responses from relays that do not support this NIP. | ||
| 37 | |||
| 38 | Clients SHOULD query several relays supporting this NIP to compensate for potentially different | ||
| 39 | implementation details between relays. | ||
| 40 | |||
| 41 | Clients MAY verify that events returned by a relay match the specified query in a way that suits the | ||
| 42 | client's use case, and MAY stop querying relays that have low precision. | ||
| 43 | |||
| 44 | Relays SHOULD exclude spam from search results by default if they supports some form of spam filtering. | ||
| 45 | |||
| 46 | ## Extensions | ||
| 47 | |||
| 48 | Relay MAY support these extensions: | ||
| 49 | - `include:spam` - turn off spam filtering, if it was enabled by default | ||