Skip to main content

Content Search API

The Content Search API enables search across content indexes with faceted filtering and aggregations, allowing you to search across multiple content indexes simultaneously.

Content must first be ingested using the Contents API before it can be searched.

API Endpoint

Method: POST

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

Request Header

NameValue
Content-Typeapplication/json
AuthorizationBearer ACCESS_TOKEN

Request Parameters (Body)

ParameterTypeRequiredDefaultDescription
customer_idstringNoUUID of the customer making the request.
aliasarray of stringsYesList of content index aliases to search in.
qstringYesInput search query string.
startintegerNo0Starting offset for pagination (0-based).
sizeintegerNo10Number of results to return per alias. Maximum 100.
query_settingobjectNo{}Per-alias query settings for filtering, sorting, and aggregations.

Query Setting Object

The query_setting object allows you to configure search behavior for each content alias. Keys are content alias names, and values contain the following options:

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": "how to configure search",
"start": 0,
"size": 10,
"query_setting": {
"articles": {
"aggregations": ["category", "author"],
"range_fields": ["readTime"],
"scope": {
"category": ["Documentation", "Tutorial"],
"featured": [true]
},
"sort_fields": [
{"publishDate": {"order": "desc", "type": "date"}}
]
},
"faqs": {
"aggregations": ["category"],
"scope": {},
"sort_fields": [
{"helpful_count": {"order": "desc", "type": "number"}}
]
}
}
}

Response Payload

The response contains search results grouped by alias name.

{
"payload": {
"articles": {
"total_results": 25,
"results": [
{
"refId": "article-001",
"score": 2.45,
"indexed_at": "2024-03-15T10:00:00Z",
"contentData": {
"title": "Getting Started with Discovery OS",
"category": "Documentation",
"author": "PA Team",
"publishDate": "2024-03-15",
"tags": ["getting-started", "tutorial", "basics"],
"summary": "Learn how to integrate Discovery OS into your platform.",
"readTime": 10,
"featured": true
}
},
{
"refId": "article-005",
"score": 2.12,
"indexed_at": "2024-03-20T14:30:00Z",
"contentData": {
"title": "Advanced Search Configuration",
"category": "Documentation",
"author": "PA Team",
"publishDate": "2024-03-20",
"tags": ["search", "configuration", "advanced"],
"summary": "Deep dive into search configuration options.",
"readTime": 15,
"featured": false
}
}
],
"aggregations": {
"category": [
{"key": "Documentation", "doc_count": 15},
{"key": "Tutorial", "doc_count": 10}
],
"author": [
{"key": "PA Team", "doc_count": 20},
{"key": "Guest Author", "doc_count": 5}
]
}
},
"faqs": {
"total_results": 8,
"results": [
{
"refId": "faq-015",
"score": 1.89,
"indexed_at": "2024-03-10T09:00:00Z",
"contentData": {
"question": "How do I configure search settings?",
"answer": "Navigate to Settings > Search Configuration...",
"category": "Configuration",
"helpful_count": 156
}
}
],
"aggregations": {
"category": [
{"key": "Configuration", "doc_count": 5},
{"key": "General", "doc_count": 3}
]
}
}
}
}

Response Fields

FieldTypeDescription
payloadobjectSearch results grouped by alias name.
payload.{alias}.total_resultsintegerTotal number of matching results for this alias.
payload.{alias}.resultsarrayArray of matching content items.
payload.{alias}.results[].refIdstringUnique reference ID of the content item.
payload.{alias}.results[].scorenumberRelevance score for this result.
payload.{alias}.results[].indexed_atstringTimestamp when the content was indexed.
payload.{alias}.results[].contentDataobjectThe original content data object.
payload.{alias}.aggregationsobjectFaceted search aggregations for requested fields.

Error Response

If there are any errors, an appropriate error response will be returned:

{
"detail": "Content search timed out. Request took longer than expected. Please try again"
}

Example Usage (JavaScript)

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

const body = {
customer_id: 'aa6eab4b-7b1b-4b36-afea-20dcf9f40221',
alias: ['articles', 'faqs'],
q: 'how to configure search',
start: 0,
size: 10,
query_setting: {
articles: {
aggregations: ['category', 'author'],
scope: { category: ['Documentation'] },
sort_fields: [{ publishDate: { order: 'desc', type: 'date' } }]
},
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 => {
console.log('Content Search Results:', data);

// Process results by alias
for (const [alias, aliasResults] of Object.entries(data.payload)) {
console.log(`\n${alias}: ${aliasResults.total_results} results`);
aliasResults.results.forEach(item => {
console.log(`- ${item.refId}: ${item.contentData.title || item.contentData.question}`);
});
}
})
.catch(error => console.error('Error:', error));

Summary

  • The Content Search API enables search across content indexes.
  • Search multiple content aliases in a single request with per-alias configuration.
  • Support for filtering, sorting, and faceted aggregations on content fields.
  • Results are grouped by alias name with relevance scores and aggregation data.
  • Content must first be ingested via the Contents API before searching.
  • For combined product and content search, see the Search All API.