Skip to main content

Search All API

The Search All API (Combined Search) executes both product search and content search in parallel, returning unified results in a single response. This is ideal for implementing universal search experiences that span products and content.

API Endpoint

Method: POST

URL: https://<PA_SEARCH_END_POINT>/search/all

Request Header

NameValue
Content-Typeapplication/json
AuthorizationBearer ACCESS_TOKEN

Request Parameters (Body)

ParameterTypeRequiredDefaultDescription
customer_idstringNoUUID of the customer making the request.
aliasarray of stringsNoList of content index aliases to search. If provided, content search runs in parallel with product search.
qstringYesText query for search.
startintegerNo0Starting offset for pagination (0-based).
sizeintegerNo10Number of results to return. Maximum 100.
query_settingobjectNo{}Query settings per result type. Use "products" key for product search settings and alias names for content search.

Query Setting Object

The query_setting object allows you to configure search behavior for products and each content alias:

For Products ("products" key):

ParameterTypeDescription
aggregationsarray of stringsList of fields to aggregate for faceted search.
range_fieldsarray of stringsList of numeric fields for range filtering.
scopeobjectFilter criteria. Keys are field names, values are filter values or range objects.
sort_fieldsarray of objectsSort specifications. Each object has field name as key with order and type properties.

For Content Aliases (alias name as key):

ParameterTypeDescription
aggregationsarray of stringsList of fields to aggregate for faceted search.
range_fieldsarray of stringsList of numeric fields for range filtering.
scopeobjectFilter criteria. Keys are field names, values are filter values or range objects.
sort_fieldsarray of objectsSort specifications. Each object has field name as key with order and type properties.

Example Request Payload

{
"customer_id": "aa6eab4b-7b1b-4b36-afea-20dcf9f40221",
"alias": ["articles", "faqs"],
"q": "running shoes",
"start": 0,
"size": 10,
"query_setting": {
"products": {
"aggregations": ["product_category", "brand"],
"range_fields": ["sale_price"],
"scope": {
"sale_price": {"min": 50, "max": 200}
},
"sort_fields": [
{"sale_price": {"order": "asc", "type": "number"}}
]
},
"articles": {
"aggregations": ["category"],
"scope": {
"category": ["Footwear", "Sports"]
},
"sort_fields": [
{"publishDate": {"order": "desc", "type": "date"}}
]
},
"faqs": {
"aggregations": ["category"]
}
}
}

Response Payload

The response contains search results grouped by products key (for product search) and alias names (for content search).

{
"type": 1,
"code": 0,
"payload": {
"products": {
"total_results": 150,
"next_cursor": null,
"aggregations": {
"product_category": [
{"key": "Footwear", "doc_count": 80},
{"key": "Sports", "doc_count": 70}
],
"brand": [
{"key": "Nike", "doc_count": 45},
{"key": "Adidas", "doc_count": 40},
{"key": "New Balance", "doc_count": 35}
]
},
"result": [
{
"refId": "SHOE-001",
"title": "UltraBoost Running Shoes",
"score": 0.95,
"attributes": {
"sale_price": 129.99,
"brand": "Adidas",
"product_category": "Footwear"
}
},
{
"refId": "SHOE-002",
"title": "Air Max Running Shoes",
"score": 0.92,
"attributes": {
"sale_price": 149.99,
"brand": "Nike",
"product_category": "Footwear"
}
}
],
"settings": {
"model_id": "abc123-model-id",
"model_version": "v1",
"embedding_configuration_id": "xyz789-embedding-config-id",
"ats_model": "v1:abc123-model-id"
}
},
"articles": {
"total_results": 12,
"results": [
{
"refId": "article-025",
"score": 2.15,
"indexed_at": "2024-03-18T10:00:00Z",
"contentData": {
"title": "Choosing the Right Running Shoes",
"category": "Footwear",
"author": "Fitness Expert",
"publishDate": "2024-03-18",
"summary": "A comprehensive guide to finding your perfect running shoes."
}
}
],
"aggregations": {
"category": [
{"key": "Footwear", "doc_count": 8},
{"key": "Sports", "doc_count": 4}
]
}
},
"faqs": {
"total_results": 5,
"results": [
{
"refId": "faq-042",
"score": 1.75,
"indexed_at": "2024-03-10T09:00:00Z",
"contentData": {
"question": "What size running shoes should I buy?",
"answer": "Running shoes typically run half a size smaller...",
"category": "Sizing",
"helpful_count": 234
}
}
],
"aggregations": {
"category": [
{"key": "Sizing", "doc_count": 3},
{"key": "Care", "doc_count": 2}
]
}
}
}
}

Response Fields

FieldTypeDescription
typeintegerResponse type. 1 = success, -1 = failed.
codeintegerResponse code. 0 = normal.
payloadobjectSearch results grouped by products key and content alias names.
payload.productsobjectProduct search results.
payload.{alias}objectContent search results keyed by alias name.
errorsobjectOptional. Error details if any search failed. Keys: "v1_4", "content".

Product Results Structure

FieldTypeDescription
total_resultsintegerTotal number of matching products.
next_cursorstringCursor for next page (if applicable).
aggregationsobjectFaceted search aggregations.
resultarrayArray of matching products.
settingsobjectATS model metadata (only present when semantic search is enabled). Contains model_id, model_version, embedding_configuration_id, and ats_model.

Content Results Structure

FieldTypeDescription
total_resultsintegerTotal number of matching content items.
resultsarrayArray of matching content items.
aggregationsobjectFaceted search aggregations.

Partial Success Response

If one search type fails while the other succeeds, partial results are returned:

{
"type": 1,
"code": 0,
"payload": {
"products": {
"total_results": 150,
"result": [...]
}
},
"errors": {
"content": "Content search timed out"
}
}

Error Response

If all searches fail:

{
"type": -1,
"code": 0,
"payload": {},
"errors": {
"v1_4": "Product search failed: connection timeout",
"content": "Content search failed: invalid alias"
}
}

Example Usage (JavaScript)

const apiUrl = 'https://<PA_SEARCH_END_POINT>/search/all';
const accessToken = 'YOUR_ACCESS_TOKEN';

const body = {
customer_id: 'aa6eab4b-7b1b-4b36-afea-20dcf9f40221',
alias: ['articles', 'faqs'],
q: 'running shoes',
start: 0,
size: 10,
query_setting: {
products: {
aggregations: ['product_category', 'brand'],
scope: { sale_price: { min: 50, max: 200 } },
sort_fields: [{ sale_price: { order: 'asc', type: 'number' } }]
},
articles: {
aggregations: ['category']
},
faqs: {
aggregations: ['category']
}
}
};

fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${accessToken}`
},
body: JSON.stringify(body)
})
.then(response => response.json())
.then(data => {
if (data.type === 1) {
console.log('Search Results:', data.payload);

// Process product results
if (data.payload.products) {
console.log(`\nProducts: ${data.payload.products.total_results} results`);
data.payload.products.result.forEach(product => {
console.log(`- ${product.title} ($${product.attributes.sale_price})`);
});
}

// Process content results
['articles', 'faqs'].forEach(alias => {
if (data.payload[alias]) {
console.log(`\n${alias}: ${data.payload[alias].total_results} results`);
data.payload[alias].results.forEach(item => {
console.log(`- ${item.contentData.title || item.contentData.question}`);
});
}
});

// Check for partial errors
if (data.errors) {
console.warn('Partial errors:', data.errors);
}
} else {
console.error('Search failed:', data.errors);
}
})
.catch(error => console.error('Error:', error));

Summary

  • The Search All API combines product search and content search in a single parallel request.
  • Product search runs in parallel with content search.
  • Content search runs only if alias is provided in the request.
  • Results are keyed by products (for product search) and alias names (for content search).
  • Supports configuration for filtering, sorting, and aggregations per result type.
  • Gracefully handles partial failures, returning successful results even if one search type fails.
  • For product-only search, see the Search API.
  • For content-only search, see the Content Search API.