Skip to content

Commit 67b44b6

Browse files
committed
deprecate old search endpoint
1 parent 49ce3d2 commit 67b44b6

File tree

6 files changed

+62
-27
lines changed

6 files changed

+62
-27
lines changed

docs/api-reference/v2/endpoints/search/get-search.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ title: "Search"
33
openapi: firework-v2-openapi get /search/
44
---
55

6+
<Warning>
7+
**DEPRECATED:** This endpoint should be replaced by
8+
[/firework/v4/events/global/_search <Icon icon="code" size={16} />](/api-reference/v4/endpoints/global-search)
9+
</Warning>
10+
611
import GlobalSearchApiQuotaNote from '/snippets/global-search-api-quota-note.mdx';
712

8-
<GlobalSearchApiQuotaNote />
13+
<GlobalSearchApiQuotaNote />

docs/api-reference/v2/endpoints/search/post-search.mdx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ openapi: firework-v2-openapi post /search/
33
title: Search
44
---
55

6+
<Warning>
7+
**DEPRECATED:** This endpoint should be replaced by
8+
[/firework/v4/events/global/_search <Icon icon="code" size={16} />](/api-reference/v4/endpoints/global-search)
9+
</Warning>
10+
611
import GlobalSearchApiQuotaNote from '/snippets/global-search-api-quota-note.mdx';
712

8-
<GlobalSearchApiQuotaNote />
13+
<GlobalSearchApiQuotaNote />

docs/api-reference/v4/endpoints/global-search.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Search (new)"
2+
title: "Search"
33
api: "POST https://api.flare.io/firework/v4/events/global/_search"
44
---
55

docs/guides/global-search.mdx

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "Search in All of Flare's Events"
33
---
44

55
Global searches in Flare is exposed through the
6-
[/search <Icon icon="code" size={16} />](/api-reference/v2/endpoints/search/get-search)
6+
[global/_search <Icon icon="code" size={16} />](/api-reference/v4/endpoints/global-search)
77
endpoint.
88

99
This guide details a typical search use case and provides an example for how to impement it.
@@ -20,12 +20,10 @@ To achieve the desired results, the following parameters will be used:
2020

2121
| Parameter | Value | Justification |
2222
| --------- | ----- | ------------- |
23-
| query | fraud | The keyword we are looking for. |
24-
| lite | true | Quickly browse results, but don't ask for the full content. |
25-
| types[] | chat_message | Retrieve only the chat_message events. |
23+
| query.query_string | fraud | The keyword we are looking for. |
24+
| filter.types | chat_message | Retrieve only the chat_message events. |
2625
| order | asc | Retrieve results in ascending order so that we can resume fetching in the future. |
27-
| times | `<from_date>@` | Replace `<from_date>` with a timestamp that corresponds to 6 hours ago and don't set anything after the `@` so that we can fetch all results until the current time. |
28-
| sort_by | searchable | Sort results in the order that they have been added to Flare's database. |
26+
| filter.estimated_created_at.gte | `<from_date>` | Replace `<from_date>` with a timestamp that corresponds to 6 hours that we can fetch all results until the current time.
2927

3028

3129
## Paging
@@ -50,6 +48,7 @@ These are end-to-end examples in various programming languages.
5048
import datetime
5149
import os
5250
import time
51+
import urllib.parse
5352

5453
from flareio import FlareApiClient
5554

@@ -68,29 +67,51 @@ last_from: str | None = None
6867
fetched_pages: int = 0
6968

7069
for resp in api_client.scroll(
71-
method="GET",
72-
url="/firework/v2/search/",
73-
params={
74-
"query": "fraud",
75-
"lite": "true",
70+
method="POST",
71+
url="/firework/v4/events/global/_search",
72+
json={
73+
"size": 10,
7674
"order": "asc",
77-
"sort_by": "searchable",
78-
"types[]": "chat_message",
79-
"time": f"{from_timestamp}@",
8075
"from": None,
76+
"filters": {
77+
"type": ["chat_message"],
78+
"estimated_created_at": {"gte": from_timestamp},
79+
},
80+
"query": {
81+
"type": "query_string",
82+
"query_string": "hello",
83+
},
8184
},
8285
):
8386
# Rate limiting.
8487
time.sleep(1)
8588

8689
resp_data: dict = resp.json()
90+
items: list[dict] = resp_data["items"]
8791

8892
fetched_pages += 1
89-
num_results: int = len(resp_data["items"])
90-
print(f"Fetched page {fetched_pages} with {num_results} results...")
93+
print(f"Fetched page {fetched_pages} with {len(items)} results...")
9194

9295
# Save the last "next" value.
9396
last_from = resp_data.get("next") or last_from
97+
98+
# (Optional): Get the full data
99+
for item in items:
100+
# Rate limiting.
101+
time.sleep(1)
102+
103+
# This will contain 3 parts: 'index', 'source', and 'id'
104+
parsed_uid: list[str] = item["metadata"]["uid"].split("/", maxsplit=2)
105+
106+
event_response = api_client.get(
107+
"/firework/v2/activities/"
108+
+ "/".join(
109+
urllib.parse.quote_plus(uid_component) for uid_component in parsed_uid
110+
)
111+
)
112+
113+
full_data = event_response.json()
114+
print(f"Here is the full data of the event: {full_data}")
94115
```
95116
</Accordion>
96117

docs/guides/tenant-events.mdx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,25 +132,24 @@ for resp in api_client.scroll(
132132
# Save the last "next" value.
133133
last_from = resp_data.get("next") or last_from
134134

135-
# Get the full data
135+
# (Optional): Get the full data
136136
for item in resp_data["items"]:
137137
# Rate limiting.
138138
time.sleep(1)
139139

140140
# This will contain 3 parts: 'index', 'source', and 'id'
141141
parsed_uid: list[str] = item["metadata"]["uid"].split("/", maxsplit=2)
142142

143-
response = api_client.get(
143+
event_response = api_client.get(
144144
"/firework/v2/activities/"
145145
+ "/".join(
146146
urllib.parse.quote_plus(uid_component) for uid_component in parsed_uid
147147
)
148148
)
149149

150-
full_data = response.json()
150+
full_data = event_response.json()
151151
print(f"Here is the full data of the event: {full_data}")
152152
```
153153
</Accordion>
154154

155155
</AccordionGroup>
156-

docs/mint.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,8 @@
185185
{
186186
"group": "Global Search",
187187
"pages": [
188-
"api-reference/v4/endpoints/global-search",
189-
"api-reference/v2/endpoints/search/get-search",
190-
"api-reference/v2/endpoints/search/post-search"
191-
]
188+
"api-reference/v4/endpoints/global-search"
189+
]
192190
}
193191
]
194192
},
@@ -279,6 +277,13 @@
279277
{
280278
"group": "Deprecated APIs",
281279
"pages": [
280+
{
281+
"group": "Global Search",
282+
"pages": [
283+
"api-reference/v2/endpoints/search/get-search",
284+
"api-reference/v2/endpoints/search/post-search"
285+
]
286+
},
282287
{
283288
"group": "Identities",
284289
"pages": [

0 commit comments

Comments
 (0)