For the complete documentation index, see llms.txt. This page is also available as Markdown.

AI RAG Indexer Tutorial

You can use the AI RAG Indexer Service to keep your vector database in sync with Emporix data and to discover which attributes are available for Retrieval-Augmented Generation (RAG) and filtering. The service supports the built-in product and order entity types, and custom entity types created in the Schema Service.

Follow this tutorial to learn how to create a RAG tool with indexable and filterable fields that you can use in an AI agent.

Prerequisites

  • The OAuth2 access token must include the ai.agent_read and ai.agent_manage scopes.

  • For built-in entity types, use product or order as the {type} path parameter.

  • For custom entities, the custom type must exist in the Schema Service. The {type} in indexer URLs must match the config.entityType.

How to prepare RAG indexing

1

Discover indexable fields

Before creating a RAG tool, call the AI RAG Indexer metadata endpoints for your entity type.

Call the Listing fields for RAG search endpoint to get the RAG fields.

curl -L \
  --request GET \
  --url 'https://api.emporix.io/ai-rag-indexer/{{tenant}}/product/rag-metadata' \
  --header 'Authorization: Bearer {{OAUTH2_ACCESS_TOKEN}}' \
  --header 'Accept: application/json'

Sample response:

[
  "code",
  "name.en",
  "labels.description.de",
  "mixins.additionalattributes.temperature",
  "segmentIds"
]
curl -L \
  --request GET \
  --url 'https://api.emporix.io/ai-rag-indexer/{{tenant}}/order/rag-metadata' \
  --header 'Authorization: Bearer {{OAUTH2_ACCESS_TOKEN}}' \
  --header 'Accept: application/json'

Sample response:

[
  "id",
  "status",
  "customer.email",
  "customer.firstName",
  "customer.lastName",
  "customer.company",
  "siteCode",
  "currency",
  "entries",
  "shippingAddress.city",
  "billingAddress.city"
]

Sample response (field paths depend on your custom schema):

Replace the sample paths with the values returned by rag-metadata for your tenant. Mixin keys must match your Schema Service attribute definitions.

Use the response paths in the indexedFields[].key when you create a RAG tool in the upcoming step.

API Reference
2

Discover filterable fields

Call the Listing fields for vector search filtering endpoint to retrieve the field paths for filtering search.

curl -L \
  --request GET \
  --url 'https://api.emporix.io/ai-rag-indexer/{{tenant}}/product/filter-metadata' \
  --header 'Authorization: Bearer {{OAUTH2_ACCESS_TOKEN}}' \
  --header 'Accept: application/json'

Sample response:

[
  { "key": "code", "type": "string" },
  { "key": "id", "type": "string" },
  { "key": "published", "type": "boolean" },
  { "key": "segmentIds", "type": "list" }
]
curl -L \
  --request GET \
  --url 'https://api.emporix.io/ai-rag-indexer/{{tenant}}/order/filter-metadata' \
  --header 'Authorization: Bearer {{OAUTH2_ACCESS_TOKEN}}' \
  --header 'Accept: application/json'

Sample response:

[
  { "key": "id", "type": "string" },
  { "key": "status", "type": "string" },
  { "key": "customer.email", "type": "string" },
  { "key": "siteCode", "type": "string" },
  { "key": "currency", "type": "string" },
  { "key": "legalEntityId", "type": "string" }
]

Sample response (field paths depend on your custom schema):

Use the returned field paths in filterFields[].key when creating a tool in the upcoming step.

API Reference
3

Create an AI tool using RAG functionality

When you know which fields to index and filter, call the Upserting tool endpoint to create or update a rag_emporix tool.

Set the toolId in the URL path (for example, rag-product, rag-order, or rag-car-parts). The indexedFields and filterFields are required for rag_emporix tools – specify the paths from the responses returned in previous steps:

  • The indexedFields can use optional name aliases.

  • For the filterFields, add relevant descriptions so that the agent knows when to apply the filters.

curl --request PUT \
  'https://api.emporix.io/ai-service/{{tenant}}/agentic/tools/rag-product' \
  --header 'Authorization: Bearer {{OAUTH2_ACCESS_TOKEN}}' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "Product Search RAG Tool",
    "type": "rag_emporix",
    "enabled": true,
    "config": {
      "prompt": "Use this tool when the user asks to find, compare, or look up products in the catalog.",
      "entityType": "product",
      "embeddingConfig": {
        "provider": "emporix_openai"
      },
      "indexedFields": [
        { "key": "code", "name": "Product code" },
        { "key": "name.en", "name": "English name" },
        { "key": "description.en", "name": "English description" }
      ],
      "filterFields": [
        {
          "key": "code",
          "name": "Product code",
          "description": "Exact product SKU or catalog code. Use when the user provides a specific product code."
        },
        {
          "key": "published",
          "name": "Published",
          "description": "Set to true when the user should only see products visible in the catalog."
        },
        {
          "key": "segmentIds",
          "name": "Customer segments",
          "description": "List of segment IDs. Use when results must be limited to products available for specific customer segments."
        }
      ]
    }
  }'

Align indexedFields and filterFields with the output of rag-metadata and filter-metadata for your tenant.

API Reference
4

Trigger a reindex job

When the tool is configured, call the Creating a reindex job endpoint to regenerate embeddings for the selected entity type. The reindex endpoint currently performs a full rebuild.

curl -L \
  --request POST \
  --url 'https://api.emporix.io/indexing/{{tenant}}/reindex-jobs' \
  --header 'Authorization: Bearer {{OAUTH2_ACCESS_TOKEN}}' \
  --header 'Content-Type: application/json' \
  --data '{
    "entityType": "PRODUCT",
    "rag": true
  }'

For products, set "rag": true so the reindex job generates vector embeddings for your rag_emporix tool, using the indexedFields defined in the tool configuration. Without this flag, only the storefront search index is rebuilt; the vector database used for RAG retrieval is not updated.

curl -L \
  --request POST \
  --url 'https://api.emporix.io/indexing/{{tenant}}/reindex-jobs' \
  --header 'Authorization: Bearer {{OAUTH2_ACCESS_TOKEN}}' \
  --header 'Content-Type: application/json' \
  --data '{
    "entityType": "ORDER",
    "rag": true
  }'

For orders, set "rag": true so the reindex job generates vector embeddings for your rag_emporix tool, using the indexedFields defined in the tool configuration.

The service fetches every entity of the specified type (product, order, or custom entity type). Embeddings are generated per entity and vector database records are updated. You receive a 201 or 200 response with a reindex job ID, which allows you to track the progress.

API Reference
5

Attach the tool to an agent

Assign the tool ID (for example, rag-product, rag-order, or rag-car-parts) to an AI agent so it can be invoked during agentic chat. Use the Upserting agent endpoint or configure the agent in Management Dashboard.

For broader agent setup and chat flows, see the AI Service Tutorial.

Last updated

Was this helpful?