2023-01-17 15:49:10 +00:00
|
|
|
NIP-50
|
|
|
|
======
|
|
|
|
|
2023-01-27 12:43:06 +00:00
|
|
|
Keyword Search
|
|
|
|
--------------
|
2023-01-17 15:49:10 +00:00
|
|
|
|
2023-01-27 12:43:06 +00:00
|
|
|
`draft` `optional` `author:brugeman` `author:mikedilger` `author:fiatjaf`
|
2023-01-17 15:49:10 +00:00
|
|
|
|
|
|
|
## Abstract
|
|
|
|
|
2023-01-27 12:43:06 +00:00
|
|
|
Many Nostr use cases require some form of general search feature, in addition to structured queries by tags or ids.
|
|
|
|
Specifics of the search algorithms will differ between event kinds, this NIP only describes a general
|
|
|
|
extensible framework for performing such queries.
|
2023-01-17 15:49:10 +00:00
|
|
|
|
2023-01-27 12:43:06 +00:00
|
|
|
## `search` filter field
|
2023-01-17 15:49:10 +00:00
|
|
|
|
2023-01-27 12:43:06 +00:00
|
|
|
A new `search` field is introduced for `REQ` messages from clients:
|
2023-01-17 15:49:10 +00:00
|
|
|
```json
|
|
|
|
{
|
2023-01-27 12:43:06 +00:00
|
|
|
...
|
|
|
|
"search": <string>
|
2023-01-17 15:49:10 +00:00
|
|
|
}
|
|
|
|
```
|
2023-01-27 12:43:06 +00:00
|
|
|
`search` field is a string describing a query in a human-readable form, i.e. "best nostr apps".
|
|
|
|
Relays SHOULD interpret the query to the best of their ability and return events that match it.
|
|
|
|
Relays SHOULD perform matching against `content` event field, and MAY perform
|
|
|
|
matching against other fields if that makes sense in the context of a specific kind.
|
2023-01-17 15:49:10 +00:00
|
|
|
|
2023-01-27 12:43:06 +00:00
|
|
|
A query string may contain `key:value` pairs (two words separated by colon), these are extensions, relays SHOULD ignore
|
|
|
|
extensions they don't support.
|
2023-01-17 15:49:10 +00:00
|
|
|
|
2023-01-27 12:43:06 +00:00
|
|
|
Clients may specify several search filters, i.e. `["REQ", "", [{"search":"orange"},{"search":"purple"}]`. Clients may
|
|
|
|
include `kinds`, `ids` and other filter field to restrict the search results to particular event kinds.
|
2023-01-24 06:03:59 +00:00
|
|
|
|
2023-01-27 12:43:06 +00:00
|
|
|
Clients SHOULD use the supported_nips field to learn if a relay supports `search` filter. Clients MAY send `search`
|
|
|
|
filter queries to any relay, if they are prepared to filter out extraneous responses from relays that do not support this NIP.
|
2023-01-17 15:49:10 +00:00
|
|
|
|
2023-01-27 12:43:06 +00:00
|
|
|
Clients SHOULD query several relays supporting this NIP to compensate for potentially different
|
|
|
|
implementation details between relays.
|
2023-01-17 15:49:10 +00:00
|
|
|
|
2023-01-27 12:43:06 +00:00
|
|
|
Clients MAY verify that events returned by a relay match the specified query in a way that suits the
|
|
|
|
client's use case, and MAY stop querying relays that have low precision.
|
2023-01-17 15:49:10 +00:00
|
|
|
|
2023-01-27 12:43:06 +00:00
|
|
|
Relays SHOULD exclude spam from search results by default if they supports some form of spam filtering.
|
2023-01-17 15:49:10 +00:00
|
|
|
|
2023-01-27 12:43:06 +00:00
|
|
|
## Extensions
|
2023-01-17 15:49:10 +00:00
|
|
|
|
2023-01-27 12:43:06 +00:00
|
|
|
Relay MAY support these extensions:
|
|
|
|
- `include:spam` - turn off spam filtering, if it was enabled by default
|