Send a JSON File to Your Index, Step by Step

Email, API key, index name, the file and one command

Your documents are in a .json file and you want them in your Opensolr Index. You need three things from your account, the file, and one command typed in the terminal of your computer. No programming.

1. Your account email

The email you sign in to Opensolr with.

2. Your API key

Open Account › API Keys. Under Master API key, click Copy. Keep it to yourself: it opens your whole account. More: API authentication.

3. The name of your index

The name in your list of indexes on the Dashboard, written exactly as it is there. It is also the last part of the address of the index control panel: in https://opensolr.com/admin/solr_manager/tools/my_products the name is my_products.

4. The file

Save your documents in a file named, for example, my_documents.json, in your Downloads folder. The file is a list between [ and ], one document between { and }, separated by commas. Every document has a uri (its web address), a title, a description and a text. At most 50 documents in one file.

[
  {"uri": "https://example.com/page-1", "title": "Page one", "description": "First page", "text": "Full text of page one."},
  {"uri": "https://example.com/page-2", "title": "Page two", "description": "Second page", "text": "Full text of page two."}
]

The other fields you can add: Document fields.

5. Open the terminal

  • Mac: open Terminal (Applications › Utilities › Terminal).
  • Windows: open Command Prompt (type cmd in the Start menu).
  • Linux: open your terminal.

Go to the folder of the file. Type this and press Enter:

cd Downloads

6. Send the file

Copy the command below, put your email, your API key and your index name in place of the three examples, paste it in the terminal and press Enter. It is one line: keep it on one line.

curl -X POST "https://api.opensolr.com/solr_manager/api/ingest" -F "email=you@example.com" -F "api_key=YOUR_API_KEY" -F "core_name=YOUR_INDEX_NAME" -F "payload_file=@my_documents.json"

7. Read the answer

The terminal prints one line. This one means the documents are on their way into your index:

{"status":true,"msg":"QUEUED","job_id":"3f9c2a7e5b1d4c8a9e0f6b2d7c4a1e58","total_docs":2, ...}
  • "status":false means nothing was sent: msg says why. ERROR_AUTHENTICATION_FAILED = the email or the API key is not right: copy them again (steps 1 and 2).
  • ERROR_INVALID_JSON_IN_UPLOADED_FILE = the file is not written right: check the brackets, the quotes and the commas.
  • curl: (26) Failed to open/read local data = the file is not in the folder you are in, or its name is not the one in the command.
  • Every other answer: Limits and refusals.

8. See your documents

Open Account › Data Ingestion: your job is there, with each document. When it says completed, the documents are in your index and can be searched. If a document failed, the reason is next to it: Why ingestion failed.

More than 50 documents? Split them into several files and send each one the same way.

Push your data pages

Back to Enterprise Site Search