Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Post To Meilisearch With The Python SDK

This is how I'm sending updates to Meilisearch via Python with authenciation via values stored in the default Keycain Access mac app and the python keyring library. (keyring works on other operating systems as well if you're not on a mac)

Code

import json
  import keyring
  import meilisearch


  domain = "http://localhost:7700"
  admin_key = keyring.get_password(
      'alan--meilisearch--scratchpad--admin-key',
      'alan'
  )

  client = meilisearch.Client(
      domain,
      admin_key
  )

  documents = [
      { "id": "file-1", "content": "this is file one" },
      { "id": "file-2", "content": "second file here" },
      { "id": "file-3", "content": "take three" }
  ]

  response = client.index('test-6').add_documents(documents)

  print(json.dumps(response, sort_keys=True, indent=2, default=str))

#+RESULTS: : { : "enqueuedAt": "2022-05-24T22:02:19.643685Z", : "indexUid": "test-6", : "status": "enqueued", : "type": "documentAddition", : "uid": 10171 : }