Documents

To import your Documents, you can use Lupa dashboard or API.

Importing documents using API

You can use Document Import API to import your documents to the newly created index.

This section will refer to simple Appending strategy. For more advanced used cases and document Replacement concepts, please check Documents - Advanced.

  1. To append new documents to the Index, issue an HTTP POST request:
/v1/indices/{indexId}/documents

Replace indexId with the id of the index, created in the previous steps.

The request body should consist of your Documents in the following format:

{
  "documents": [
    {
      "id": 1, "name": "Samsung Television", "category": ["Electronics"], "rating": 5
    },
    {
      "id": 2, "name": "Beko Refrigerator", "category": ["Home Appliances"], "rating": 4
    },
    {
      "id": 3, "name": "LG Television", "category": ["Electronics"], "rating": 4
    },
    {
      "id": 4, "name": "Television Set", "category": ["Electronics"], "rating": 3
    },
    {
      "id": 5, "name": "Televisions", "category": ["Electronics"], "rating": 2
    }
  ]
}

If you have a large amount of documents, you can split the import into multiple requests. Maximum single request body size should not exceed 10 MB.

  1. Once all of the documents are uploaded, refer to the Task API to check the progress. However, for a small number of documents, the import process should be almost instantaneous.

Importing documents using Lupa Dashboard

Import through the Lupa dashboard should only be used for testing/debugging purposes, as any page reload will stop the import process.

  1. Select your Organization, Project and Index, if you have more than one;

  2. Navigate to Document Import Page;

  3. Select your documents from .json files - you can choose one or multiple files.

Each .json file should have a following format, matching Mapping configuration, created in the previous step:

[
  {
    "id": 1, "name": "Samsung Television", "category": ["Electronics"], "rating": 5
  },
  {
    "id": 2, "name": "Beko Refrigerator", "category": ["Home Appliances"], "rating": 4
  },
  {
    "id": 3, "name": "LG Television", "category": ["Electronics"], "rating": 4
  },
  {
    "id": 4, "name": "Television Set", "category": ["Electronics"], "rating": 3
  },
  {
    "id": 5, "name": "Televisions", "category": ["Electronics"], "rating": 2
  }
]

You will see the preview of the first item in the list.

  1. Once all documents are loaded, select the type of the import: Append Documents or Replace Documents.

Append Documents will append the new documents to the existing ones (if there are any). If document id matches, the new documents will override the old ones.

Replace Documents will remove all existing documents (if there are any) before importing new ones.

  1. Wait for the document upload to be finished.

Once all of the documents are uploaded, Lupa will perform asynchronous document index. To check the progress - use Task API. However, for small number of documents, the import should be almost instantaneous.

Next steps

After documents are imported, we can start configuring the Queries.

Continue

See more: