eBay-Style Marketplace Backend

frontend-prompt-9-searchindexingservice • 1/2/2026

EBAYCCLONE

FRONTEND GUIDE FOR AI CODING AGENTS - PART 9 - SearchIndexing Service

This document is a part of a REST API guide for the ebaycclone project. It is designed for AI agents that will generate frontend code to consume the project’s backend.

This document provides extensive instruction for the usage of searchIndexing

Service Access

SearchIndexing service management is handled through service specific base urls.

SearchIndexing service may be deployed to the preview server, staging server, or production server. Therefore,it has 3 access URLs. The frontend application must support all deployment environments during development, and the user should be able to select the target API server on the login page (already handled in first part.).

For the searchIndexing service, the base URLs are:

  • Preview: https://ebaycclone.prw.mindbricks.com/searchindexing-api
  • Staging: https://ebaycclone-stage.mindbricks.co/searchindexing-api
  • Production: https://ebaycclone.mindbricks.co/searchindexing-api

Scope

SearchIndexing Service Description

Maintains the denormalized search index (materialized view) for global, public search across products, sellers, categories, and subcategories. Handles indexing in response to entity events and exposes optimized query endpoints for BFF/aggregator.

SearchIndexing service provides apis and business logic for following data objects in ebaycclone application. Each data object may be either a central domain of the application data structure or a related helper data object for a central concept. Note that data object concept is equal to table concept in the database, in the service database each data object is represented as a db table scheme and the object instances as table rows.

searchIndex Data Object: Materialized/denormalized search index record for a marketplace entity (product, seller, category, subcategory). Used exclusively for high-speed querying in BFF global/public search.

SearchIndexing Service Frontend Description By The Backend Architect

SearchIndexing Service UX Notes

  • This is an internal service; there is no direct frontend. All query/search UX is handled through BFF by reading from here.
  • Data is always denormalized (copy of product/seller/category/subcategory), so cache can be safely used.
  • If search returns fewer items than expected or appears stale, an admin may trigger a forced 'rebuild' via backend tools (not user-triggerable).

API Structure

Object Structure of a Successful Response

When the service processes requests successfully, it wraps the requested resource(s) within a JSON envelope. This envelope includes the data and essential metadata such as configuration details and pagination information, providing context to the client.

HTTP Status Codes:

  • 200 OK: Returned for successful GET, LIST, UPDATE, or DELETE operations, indicating that the request was processed successfully.
  • 201 Created: Returned for CREATE operations, indicating that the resource was created successfully.

Success Response Format:

For successful operations, the response includes a "status": "OK" property, signaling that the request executed successfully. The structure of a successful response is outlined below:

{
  "status":"OK",
  "statusCode": 200,   
  "elapsedMs":126,
  "ssoTime":120,
  "source": "db",
  "cacheKey": "hexCode",
  "userId": "ID",
  "sessionId": "ID",
  "requestId": "ID",
  "dataName":"products",
  "method":"GET",
  "action":"list",
  "appVersion":"Version",
  "rowCount":3,
  "products":[{},{},{}],
  "paging": {
    "pageNumber":1, 
    "pageRowCount":25, 
    "totalRowCount":3,
    "pageCount":1
  },
  "filters": [],
  "uiPermissions": []
}
  • products: In this example, this key contains the actual response content, which may be a single object or an array of objects depending on the operation.

Additional Data

Each API may include additional data besides the main data object, depending on the business logic of the API. These will be provided in each API’s response signature.

Error Response

If a request encounters an issue—whether due to a logical fault or a technical problem—the service responds with a standardized JSON error structure. The HTTP status code indicates the nature of the error, using commonly recognized codes for clarity:

  • 400 Bad Request: The request was improperly formatted or contained invalid parameters.
  • 401 Unauthorized: The request lacked a valid authentication token; login is required.
  • 403 Forbidden: The current token does not grant access to the requested resource.
  • 404 Not Found: The requested resource was not found on the server.
  • 500 Internal Server Error: The server encountered an unexpected condition.

Each error response is structured to provide meaningful insight into the problem, assisting in efficient diagnosis and resolution.

{
  "result": "ERR",
  "status": 400,
  "message": "errMsg_organizationIdisNotAValidID",
  "errCode": 400,
  "date": "2024-03-19T12:13:54.124Z",
  "detail": "String"
}

Bucket Management

(This information is also given in PART 1 prompt.)

This application has a bucket service used to store user files and other object-related files. The bucket service is login-agnostic, so for write operations or private reads, include a bucket token (provided by services) in the request’s Authorization header as a Bearer token.

Please note that all other business services require the access token in the Bearer header, while the bucket service expects a bucket token because it is login-agnostic. Ensure you manage the required token injection properly; any auth interceptor should not replace the bucket token with the access token.

User Bucket This bucket stores public user files for each user.

When a user logs in—or in the /currentuser response—there is a userBucketToken to use when sending user-related public files to the bucket service.

{
  //...
  "userBucketToken": "e56d...."
}

To upload a file

POST {baseUrl}/bucket/upload

The request body is form-data which includes the bucketId and the file binary in the files field.

{
    bucketId: "{userId}-public-user-bucket",
    files: {binary}
}

Response status is 200 on success, e.g., body:

{
    "success": true,
    "data": [
        {
            "fileId": "9da03f6d-0409-41ad-bb06-225a244ae408",
            "originalName": "test (10).png",
            "mimeType": "image/png",
            "size": 604063,
            "status": "uploaded",
            "bucketName": "f7103b85-fcda-4dec-92c6-c336f71fd3a2-public-user-bucket",
            "isPublic": true,
            "downloadUrl": "https://babilcom.mindbricks.co/bucket/download/9da03f6d-0409-41ad-bb06-225a244ae408"
        }
    ]
}

To download a file from the bucket, you need its fileId. If you upload an avatar or other asset, ensure the download URL or the fileId is stored in the backend.

Buckets are mostly used in object creations that require an additional file, such as a product image or user avatar. After uploading your image to the bucket, insert the returned download URL into the related property of the target object record.

Application Bucket

This Ebaycclone application also includes a common public bucket that anyone can read, but only users with the superAdmin, admin, or saasAdmin roles can write (upload) to it.

When a user with one of these admin roles is logged in, the /login response or the /currentuser response also returns an applicationBucketToken field, which is used when uploading any file to the application bucket.

{
  //...
  "applicationBucketToken": "e23fd...."
}

The common public application bucket ID is

"ebaycclone-public-common-bucket"

In certain admin areas—such as product management pages—since the user already has the application bucket token, they will be able to upload related object images.

Please configure your UI to upload files to the application bucket using this bucket token whenever needed.

Object Buckets Some objects may also return a bucket token for uploading or accessing files related to that object. For example, in a project management application, when you fetch a project’s data, a public or private bucket token may be provided to upload or download project-related files.

These buckets will be used as described in the relevant object definitions.

SearchIndex Data Object

Materialized/denormalized search index record for a marketplace entity (product, seller, category, subcategory). Used exclusively for high-speed querying in BFF global/public search.

SearchIndex Data Object Frontend Description By The Backend Architect

  • Not user visible: purely backend/infra.
  • Fields mirror original entity for search; must be promptly updated/deleted with entity changes.
  • If searching returns incomplete/stale results, ask admin to trigger a reindex operation.

SearchIndex Data Object Properties

SearchIndex data object has got following properties that are represented as table fields in the database scheme. These properties don't stand just for data storage, but each may have different settings to manage the business logic.

Property Type IsArray Required Description
documentType Enum false Yes Type of the indexed document: PRODUCT, SELLER, CATEGORY, SUBCATEGORY
document Object false Yes Denormalized snapshot of the entity data, optimized for full-text search. May contain different keys depending on documentType.
referenceId ID false Yes ID of the underlying source entity (product, seller, category, subcategory) for reverse-mapping/database triggers.
indexedAt Date false Yes Timestamp when the record was (last) indexed. Used for maintenance, debugging, rebuild tracing.
  • Required properties are mandatory for creating objects and must be provided in the request body if no default value, formula or session bind is set.

Enum Properties

Enum properties are defined with a set of allowed values, ensuring that only valid options can be assigned to them. The enum options value will be stored as strings in the database, but when a data object is created an additional property with the same name plus an idx suffix will be created, which will hold the index of the selected enum option. You can use the {fieldName_idx} property to sort by the enum value or when your enum options represent a hiyerarchy of values. In the frontend input components, enum type properties should only accept values from an option component that lists the enum options.

  • documentType: [PRODUCT, SELLER, CATEGORY, SUBCATEGORY]

Filter Properties

documentType referenceId indexedAt

Filter properties are used to define parameters that can be used in query filters, allowing for dynamic data retrieval based on user input or predefined criteria. These properties are automatically mapped as API parameters in the listing API's.

  • documentType: Enum has a filter named documentType

  • referenceId: ID has a filter named referenceId

  • indexedAt: Date has a filter named indexedAt

API Reference

List Searchindexes API

List/search search index entries by type or referenceId (used by BFF/global search). Always excludes inactive (soft-deleted) records. Supports filtering and full-text search filters by documentType/referenceId for admin/maintenance use.

Rest Route

The listSearchIndexes API REST controller can be triggered via the following route:

/v1/searchindexes

Rest Request Parameters The listSearchIndexes api has got no request parameters.

REST Request To access the api you can use the REST controller with the path GET /v1/searchindexes

  axios({
    method: 'GET',
    url: '/v1/searchindexes',
    data: {
    
    },
    params: {
    
    }
  });

REST Response

{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "searchIndices",
	"method": "GET",
	"action": "list",
	"appVersion": "Version",
	"rowCount": "\"Number\"",
	"searchIndices": [
		{
			"id": "ID",
			"documentType": "Enum",
			"documentType_idx": "Integer",
			"document": "Object",
			"referenceId": "ID",
			"indexedAt": "Date",
			"isActive": true,
			"recordVersion": "Integer",
			"createdAt": "Date",
			"updatedAt": "Date",
			"_owner": "ID"
		},
		{},
		{}
	],
	"paging": {
		"pageNumber": "Number",
		"pageRowCount": "NUmber",
		"totalRowCount": "Number",
		"pageCount": "Number"
	},
	"filters": [],
	"uiPermissions": []
}

Update Searchindex API

Update an existing searchIndex record (by (documentType, referenceId) or id). Used in response to events (entity edit, data change); internal/automation/admin only.

Rest Route

The updateSearchIndex API REST controller can be triggered via the following route:

/v1/searchindexs/:searchIndexId

Rest Request Parameters

The updateSearchIndex api has got 5 request parameters

Parameter Type Required Population
searchIndexId ID true request.params?.searchIndexId
documentType Enum false request.body?.documentType
document Object true request.body?.document
referenceId ID true request.body?.referenceId
indexedAt Date false request.body?.indexedAt
searchIndexId : This id paremeter is used to select the required data object that will be updated
documentType : Type of the indexed document: PRODUCT, SELLER, CATEGORY, SUBCATEGORY
document : Denormalized snapshot of the entity data, optimized for full-text search. May contain different keys depending on documentType.
referenceId : ID of the underlying source entity (product, seller, category, subcategory) for reverse-mapping/database triggers.
indexedAt : Timestamp when the record was (last) indexed. Used for maintenance, debugging, rebuild tracing.

REST Request To access the api you can use the REST controller with the path PATCH /v1/searchindexs/:searchIndexId

  axios({
    method: 'PATCH',
    url: `/v1/searchindexs/${searchIndexId}`,
    data: {
            documentType:"Enum",  
            document:"Object",  
            referenceId:"ID",  
            indexedAt:"Date",  
    
    },
    params: {
    
    }
  });

REST Response

{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "searchIndex",
	"method": "PATCH",
	"action": "update",
	"appVersion": "Version",
	"rowCount": 1,
	"searchIndex": {
		"id": "ID",
		"documentType": "Enum",
		"documentType_idx": "Integer",
		"document": "Object",
		"referenceId": "ID",
		"indexedAt": "Date",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}

Delete Searchindex API

Soft-delete a searchIndex record (by id or by (documentType, referenceId)). Typical use: in response to entity soft-delete; internal/automation/admin only.

Rest Route

The deleteSearchIndex API REST controller can be triggered via the following route:

/v1/searchindexs/:searchIndexId

Rest Request Parameters

The deleteSearchIndex api has got 1 request parameter

Parameter Type Required Population
searchIndexId ID true request.params?.searchIndexId
searchIndexId : This id paremeter is used to select the required data object that will be deleted

REST Request To access the api you can use the REST controller with the path DELETE /v1/searchindexs/:searchIndexId

  axios({
    method: 'DELETE',
    url: `/v1/searchindexs/${searchIndexId}`,
    data: {
    
    },
    params: {
    
    }
  });

REST Response

{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "searchIndex",
	"method": "DELETE",
	"action": "delete",
	"appVersion": "Version",
	"rowCount": 1,
	"searchIndex": {
		"id": "ID",
		"documentType": "Enum",
		"documentType_idx": "Integer",
		"document": "Object",
		"referenceId": "ID",
		"indexedAt": "Date",
		"isActive": false,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}

Create Searchindex API

Create a new searchIndex record (internal, used by event triggers and admin tools only). Typically called when a new product/seller/category/subcategory is created.

Rest Route

The createSearchIndex API REST controller can be triggered via the following route:

/v1/searchindexs

Rest Request Parameters

The createSearchIndex api has got 4 request parameters

Parameter Type Required Population
documentType Enum true request.body?.documentType
document Object true request.body?.document
referenceId ID true request.body?.referenceId
indexedAt Date true request.body?.indexedAt
documentType : Type of the indexed document: PRODUCT, SELLER, CATEGORY, SUBCATEGORY
document : Denormalized snapshot of the entity data, optimized for full-text search. May contain different keys depending on documentType.
referenceId : ID of the underlying source entity (product, seller, category, subcategory) for reverse-mapping/database triggers.
indexedAt : Timestamp when the record was (last) indexed. Used for maintenance, debugging, rebuild tracing.

REST Request To access the api you can use the REST controller with the path POST /v1/searchindexs

  axios({
    method: 'POST',
    url: '/v1/searchindexs',
    data: {
            documentType:"Enum",  
            document:"Object",  
            referenceId:"ID",  
            indexedAt:"Date",  
    
    },
    params: {
    
    }
  });

REST Response

{
	"status": "OK",
	"statusCode": "201",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "searchIndex",
	"method": "POST",
	"action": "create",
	"appVersion": "Version",
	"rowCount": 1,
	"searchIndex": {
		"id": "ID",
		"documentType": "Enum",
		"documentType_idx": "Integer",
		"document": "Object",
		"referenceId": "ID",
		"indexedAt": "Date",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}

Get Searchindex API

Get a single denormalized index record (by id, or documentType+referenceId). Used by BFF for full entity search. Always excludes inactive records unless forced (admin only path).

Rest Route

The getSearchIndex API REST controller can be triggered via the following route:

/v1/searchindexs/:searchIndexId

Rest Request Parameters

The getSearchIndex api has got 1 request parameter

Parameter Type Required Population
searchIndexId ID true request.params?.searchIndexId
searchIndexId : This id paremeter is used to query the required data object.

REST Request To access the api you can use the REST controller with the path GET /v1/searchindexs/:searchIndexId

  axios({
    method: 'GET',
    url: `/v1/searchindexs/${searchIndexId}`,
    data: {
    
    },
    params: {
    
    }
  });

REST Response

{
	"status": "OK",
	"statusCode": "200",
	"elapsedMs": 126,
	"ssoTime": 120,
	"source": "db",
	"cacheKey": "hexCode",
	"userId": "ID",
	"sessionId": "ID",
	"requestId": "ID",
	"dataName": "searchIndex",
	"method": "GET",
	"action": "get",
	"appVersion": "Version",
	"rowCount": 1,
	"searchIndex": {
		"id": "ID",
		"documentType": "Enum",
		"documentType_idx": "Integer",
		"document": "Object",
		"referenceId": "ID",
		"indexedAt": "Date",
		"isActive": true,
		"recordVersion": "Integer",
		"createdAt": "Date",
		"updatedAt": "Date",
		"_owner": "ID"
	}
}

After this prompt, the user may give you new instructions to update the output of this prompt or provide subsequent prompts about the project.