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 entity types product, order, customer, and legal entity, 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_readandai.agent_managescopes. To trigger a reindex job, the token must also include theindexing.search_managescope.For built-in entity types, use
product,order,customer, orlegal-entityas the{type}path parameter.For custom entities, the custom type must exist in the Schema Service. The
{type}in indexer URLs must match theconfig.entityType.
How to prepare RAG indexing
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):
Sample response:
Sample response:
Use the response paths in the indexedFields[].key when you create a RAG tool in the upcoming step.
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):
Sample response:
Sample response:
Use the returned field paths in filterFields[].key when creating a tool in the upcoming step.
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, rag-customer, rag-legal-entity, 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
indexedFieldscan 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."
}
]
}
}'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"
}'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": "CAR_PARTS"
}'The rag flag applies only to products. Don't set it for customers.
Use LEGAL-ENTITY with a hyphen, not an underscore. The entityType value is case-insensitive. As for customers, don't set the rag flag.
The service fetches every entity of the specified type (product, order, customer, legal-entity, 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.
Attach the tool to an agent
Assign the tool ID (for example, rag-product, rag-order, rag-customer, rag-legal-entity, 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.
Last updated
Was this helpful?

