Skip to main content

Push contents to your knowledge box

A knowledge box is a collection of contents. When Nuclia runs a search, it does it over a given knowledge box. In most cases, you will just need one unique knowledge box for your application.

When creating your account, Nuclia automatically creates a default knowledge box for you.

Push files using the Nuclia Dashboard

In the Nuclia Dashboard, go to the left menu and click on Add file in the Contents section and select the files you want to push.

Indexing files might take a while, depending on the size and the nature of the file. We recommend starting with a small number of small files so you can start playing with Nuclia right away.

You can also upload some links and the corresponding web page will be indexed.

Push contents using the API


What kind of contents can be stored in a knowledge box?

In the previous example, you have created a resource containing a single file. But a resource can contain other kind of contents. These contents are stored in fields of different types:

  • file
  • text
  • link
  • conversation
  • keywords
  • datetime

Imagine you want to store employee information as a resource: the CV could be a file, the city a keyword field, their birth date a datetime field, their linkedin and twitter profiles would be link fields, notes from the company a text field, and the conversation you had with them as a conversation field.

You can define freely these content fields, and give them the id you want. Yet, a resource also has generic fields which are predefined attributes (like title, summary, labels, tags, etc.) which correspond to the Nuclia schema.

Get a service access token

In the Nuclia Dashboard, go to the left menu and click on API Keys.

Enter a title for the new service access, select the Contributor role and click on Add.

The new service access appears in the list, click on the Plus icon to create a new token.

Copy the resulting token.

Call the API


Your knowledge box API endpoint is displayed on the Nuclia Dashboard home page.

Push a file

Now you can push files to your knowledge box using the Nuclia API:

curl https://<zone><your-knowledge-box-id>/upload \
-H "X-STF-Serviceaccount: Bearer <your-service-access-token>" \
-T /path/to/file

It will automatically create a new resource in your knowledge box and store the file in it.

Resources are the entries of your Nuclia knowledge box. A resource can contain any kind of content, like a text, a video, a picture, etc.; it can contain multiple files; it also contains metadata, some of them being defined by you, some of them automatically built by Nuclia.

Push a text

Instead of uploading a file, you can also create a resource manually and provide its text content:

curl https://<zone><your-knowledge-box-id>/resources \
-H "X-STF-Serviceaccount: Bearer <your-service-access-token>" \
-H "Content-Type: application/json" \
-d '{"title":"Little Prince","texts":{"chapter-1":{"format":"PLAIN","body":"Draw me a sheep"}}}'

You can also create a resource from a link:

curl https://<zone><your-knowledge-box-id>/resources \
-H "X-STF-Serviceaccount: Bearer <your-service-access-token>" \
-H "Content-Type: application/json" \
-d '{"title":"Antoine de Saint-Exupéry","links":{"wikipedia":{"uri":""}}}'

The corresponding web page content will be indexed (but be aware that Nuclia does not act as a web crawler, it will identify all the links in the page and store them as entities in the resource, but it will not index their contents).

Push a cloud-based file

If you need to index a file stored on a Cloud service, you can send it directly to Nuclia the same way you have sent a web page in the previous example, using the files entry instead of links:

curl https://<zone><your-knowledge-box-id>/resources \
-H "X-STF-Serviceaccount: Bearer <your-service-access-token>" \
-H "Content-Type: application/json" \
-d '{"title":"Dev team weekly meeting","files":{"weekly-meeting":{"file": {"uri":"https://somecloud/path/to/meeting.mp4", "content_type": "video/mp4"}}}}'

If the file is not publicly accessible, the file entry accepts an extra_headers attribute allowing to pass authentication token or any kind of credentials.