You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
20
20
21
21
| Parameter | Value | Justification |
22
22
| --------- | ----- | ------------- |
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 | hello | The keyword we are looking for. |
24
+
| filter.types | chat_message | Retrieve only the chat_message events. |
26
25
| 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.
29
27
30
28
31
29
## Paging
@@ -50,6 +48,7 @@ These are end-to-end examples in various programming languages.
50
48
import datetime
51
49
import os
52
50
import time
51
+
import urllib.parse
53
52
54
53
from flareio import FlareApiClient
55
54
@@ -68,26 +67,48 @@ last_from: str | None = None
68
67
fetched_pages: int=0
69
68
70
69
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,
76
74
"order": "asc",
77
-
"sort_by": "searchable",
78
-
"types[]": "chat_message",
79
-
"time": f"{from_timestamp}@",
80
75
"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
+
},
81
84
},
82
85
):
83
86
# Rate limiting.
84
87
time.sleep(1)
85
88
86
89
resp_data: dict= resp.json()
90
+
items: list[dict] = resp_data["items"]
87
91
88
92
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...")
94
+
95
+
# (Optional): Get the full data
96
+
for item in items:
97
+
# Rate limiting.
98
+
time.sleep(1)
99
+
100
+
# This will contain 3 parts: 'index', 'source', and 'id'
0 commit comments