upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/50.md
diff options
context:
space:
mode:
Diffstat (limited to '50.md')
-rw-r--r--50.md43
1 files changed, 41 insertions, 2 deletions
diff --git a/50.md b/50.md
index 08ce4fd..b702d5d 100644
--- a/50.md
+++ b/50.md
@@ -26,11 +26,50 @@ Relays SHOULD interpret the query to the best of their ability and return events
26Relays SHOULD perform matching against `content` event field, and MAY perform 26Relays SHOULD perform matching against `content` event field, and MAY perform
27matching against other fields if that makes sense in the context of a specific kind. 27matching against other fields if that makes sense in the context of a specific kind.
28 28
29Results SHOULD be returned in descending order by quality of search result (as defined by the implementation),
30not by the usual `.created_at`. The `limit` filter SHOULD be applied after sorting by matching score.
31A query string may contain `key:value` pairs (two words separated by colon), these are extensions, relays SHOULD ignore 29A query string may contain `key:value` pairs (two words separated by colon), these are extensions, relays SHOULD ignore
32extensions they don't support. 30extensions they don't support.
33 31
32### Query Expression Extensions
33
34Relays MAY support query expressions with boolean operators and filter attributes. When supported, this MUST be advertised in NIP-11:
35
36```json
37{
38 "supported_nips": [50],
39 "nip50_search": {
40 "boolean_operators": true,
41 "filter_attributes": ["limit", "since", "until"]
42 }
43}
44```
45
46When `boolean_operators` is `true`, relays SHOULD support:
47
48- Terms split by whitespace (implicit AND)
49- Double quotes for phrase matching: `"hello world"`
50- Boolean operators: `AND`, `OR` (uppercase, case-sensitive)
51- Parentheses for grouping: `(cat AND dog) OR bird`
52- Operator precedence: `AND` binds tighter than `OR`
53
54Examples:
55- `hello world` → both terms required (implicit AND)
56- `hello OR world` → either term matches
57- `cat AND (dog OR bird)` → "cat" plus either "dog" or "bird"
58
59When `filter_attributes` is present, relays SHOULD support filter attributes in the query string:
60
61- `limit:<number>` - limit number of results (e.g., `limit:50`)
62- `since:<unix timestamp>` - filter events after timestamp (e.g., `since:1609459200`)
63- `until:<unix timestamp>` - filter events before timestamp (e.g., `until:1640995200`)
64
65Examples:
66- `nostr limit:50` → search "nostr" and return up to 50 results
67- `bitcoin since:1609459200` → search "bitcoin" for events after the specified time
68- `cats OR dogs limit:100 since:1640995200` → combined query with filters
69
70Results SHOULD be returned in descending order by quality of search result (as defined by the implementation),
71not by the usual `.created_at`. The `limit` filter SHOULD be applied after sorting by matching score.
72
34Clients may specify several search filters, i.e. `["REQ", "", { "search": "orange" }, { "kinds": [1, 2], "search": "purple" }]`. Clients may 73Clients may specify several search filters, i.e. `["REQ", "", { "search": "orange" }, { "kinds": [1, 2], "search": "purple" }]`. Clients may
35include `kinds`, `ids` and other filter field to restrict the search results to particular event kinds. 74include `kinds`, `ids` and other filter field to restrict the search results to particular event kinds.
36 75