Skip to content

Instantly share code, notes, and snippets.

@CyberRex0
Created May 1, 2023 14:41
Show Gist options
  • Save CyberRex0/af2676ef9ac42444bd9d3b97b4178619 to your computer and use it in GitHub Desktop.
Save CyberRex0/af2676ef9ac42444bd9d3b97b4178619 to your computer and use it in GitHub Desktop.
import orjson
import requests
import math
print('Loading notes...', end='')
with open('notes.json') as f:
notes = orjson.loads(f.read())
print('Done')
bpercent = 0
percent = 0
noteslen = len(notes)
i = 0
step = 1000
while True:
if i >= noteslen:
break
if bpercent != percent:
bpercent = percent
print(f'Adding to index... {percent}%')
r = requests.post('http://localhost:7700/indexes/misskey/documents?primaryKey=id', json=notes[i:i+step])
if r.status_code != 202:
print(f'Error ({r.status_code})')
continue
i = i + step
percent = math.floor(i / noteslen * 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment