Skip to content

Instantly share code, notes, and snippets.

@Shigawire
Last active April 12, 2017 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save Shigawire/31329bcff3e7f393186472e48d4d5183 to your computer and use it in GitHub Desktop.
Save Shigawire/31329bcff3e7f393186472e48d4d5183 to your computer and use it in GitHub Desktop.
---
title: FAQ Export
published: true
listed: false
hande: faq-export
slug: faq-export
response_type: application/json
---
{
"requests": [
{% for faq_entry in contents.faq_entries %}
{
"action": "addObject",
"body":
{
"objectID": "{{ faq_entry._id | escape }}",
"title": "{{ faq_entry.title | escape }}",
"body": "{{ faq_entry.body | strip_html | strip_newlines | escape }}",
"url": "https://<mysite>{% path_to faq_entry %}"
}
}
{% unless forloop.last %}
,
{% endunless %}
{% endfor %}
]
}
APPLICATION_ID=ALGOLIA_APP_ID API_KEY=ALGOLIA_API_KEY
curl https://<mysite>/faq-entries-export > batchFile.json
curl -X POST \
-H "X-Algolia-API-Key: ${API_KEY}" \
-H "X-Algolia-Application-Id: ${APPLICATION_ID}" \
--data-binary @batchFile.json \
"https://${APPLICATION_ID}.algolia.net/1/indexes/<algolia_index>/batch"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment