Import Fields

Import Fields

This document describes the fields used during data import into Makaira, including the request structure and document fields.

Target location: This content should be added to Getting Started > Persistence Layer or Development > Core concepts > Importer in the documentation.

Import Request Structure

Persistence Layer API

{
  "import_timestamp": "2024-01-15 10:30:00",
  "source_identifier": "my-shop-system",
  "rebuild": false,
  "items": [
    {
      "source_revision": 1,
      "delete": false,
      "language_id": "de",
      "data": {
        // Document fields here
      }
    }
  ]
}

Request Fields

FieldTypeRequiredDescription
import_timestampstringYesTimestamp of the import (yyyy-MM-dd HH:mm:ss)
source_identifierstringYesIdentifies the data source
rebuildbooleanNoSet to true for full rebuild
itemsarrayYesArray of items to import

Item Fields

FieldTypeRequiredDescription
source_revisionintegerYesVersion number from source system
deletebooleanNoSet to true to delete the document
language_idstringYesLanguage code (e.g., "de", "en")
dataobjectYesThe actual document data

Required Document Fields

Every document must include these fields:

FieldTypeDescription
idstringUnique identifier
typestringproduct, variant, category, or manufacturer
activebooleanWhether the document is active
shopstringShop identifier

Additional Required Fields by Type

Products and Variants:

FieldTypeDescription
titlestringProduct title
onstockbooleanStock availability

Variants only:

FieldTypeDescription
parentstringParent product ID
isVariantbooleanMust be true

Import Examples

Minimal Product

{
  "import_timestamp": "2024-01-15 10:30:00",
  "source_identifier": "my-shop",
  "items": [
    {
      "source_revision": 1,
      "language_id": "de",
      "data": {
        "id": "product-001",
        "type": "product",
        "active": true,
        "onstock": true,
        "shop": "shop1",
        "title": "Blue T-Shirt"
      }
    }
  ]
}

Complete Product with Variant

{
  "import_timestamp": "2024-01-15 10:30:00",
  "source_identifier": "my-shop",
  "items": [
    {
      "source_revision": 100,
      "language_id": "de",
      "data": {
        "id": "product-001",
        "type": "product",
        "active": true,
        "onstock": true,
        "hidden": false,
        "searchable": true,
        "shop": "shop1",
        "title": "Blue T-Shirt",
        "shortdesc": "Comfortable cotton t-shirt",
        "longdesc": "This premium t-shirt is made from 100% organic cotton...",
        "url": "/products/blue-t-shirt",
        "ean": "4012345678901",
        "price": 29.99,
        "stock": 100,
        "timestamp": "2024-01-15 10:30:00",
        "insert": "2024-01-01",
        "soldamount": 150,
        "rating": 4.5,
        "picture_url_main": "https://cdn.example.com/blue-t-shirt.jpg",
        "manufacturer_title": "PremiumWear",
        "category": [
          {"catid": "cat-clothing", "path": "Clothing > T-Shirts", "pos": 1}
        ],
        "attributeStr": [
          {"id": "color", "title": "Color", "value": "Blue"},
          {"id": "material", "title": "Material", "value": "Cotton"}
        ]
      }
    },
    {
      "source_revision": 101,
      "language_id": "de",
      "data": {
        "id": "variant-001-S",
        "type": "variant",
        "parent": "product-001",
        "isVariant": true,
        "active": true,
        "onstock": true,
        "shop": "shop1",
        "title": "Blue T-Shirt - Size S",
        "price": 29.99,
        "ean": "4012345678902",
        "attributeStr": [
          {"id": "size", "title": "Size", "value": "S"}
        ]
      }
    }
  ]
}

Category

{
  "source_revision": 1,
  "language_id": "de",
  "data": {
    "id": "cat-clothing",
    "type": "category",
    "active": true,
    "hidden": false,
    "shop": "shop1",
    "title": "Clothing",
    "category_title": "Clothing",
    "url": "/category/clothing",
    "depth": 1,
    "hierarchy": "cat-clothing"
  }
}

Manufacturer

{
  "source_revision": 1,
  "language_id": "de",
  "data": {
    "id": "manufacturer-premiumwear",
    "type": "manufacturer",
    "active": true,
    "shop": "shop1",
    "title": "PremiumWear",
    "manufacturer_title": "PremiumWear",
    "url": "/brands/premiumwear"
  }
}

Delete Document

{
  "source_revision": 102,
  "delete": true,
  "language_id": "de",
  "data": {
    "id": "product-to-delete",
    "type": "product"
  }
}

Generated Fields

The importer automatically generates these fields:

FieldDescription
es_idElasticsearch document ID ({id}_{datatype})
datatypeNormalized type (makaira-productgroup, makaira-product, etc.)
join_fieldParent-child relationship structure
makairaImportImport timestamp (ISO 8601)
sequenceInternal revision number
suggestAutocomplete suggestions (from title)

Rebuild vs. Delta Import

Delta Import (default)

  • Only changed documents are processed
  • Use source_revision to track changes
  • Faster for incremental updates

Full Rebuild

Set rebuild: true to:

  • Replace all documents of a type
  • Clean up orphaned data
  • Ensure index consistency
{
  "import_timestamp": "2024-01-15 10:30:00",
  "source_identifier": "my-shop",
  "rebuild": true,
  "items": [...]
}

Best Practices

  1. Unique IDs - Ensure id is unique within each type.

  2. Consistent source_revision - Increment for each change to enable delta imports.

  3. Provide all required fields - Missing required fields cause import failures.

  4. Use correct types - Match type to your document kind (product, variant, category, manufacturer).

  5. Parent before variants - Import parent products before their variants.

  6. Set timestamps - Include timestamp and insert for ranking features.