Advanced Patterns & Edge Cases - Content Management
Advanced Patterns & Edge Cases
- 10,000 Result Limit: Elasticsearch enforces a 10K result cap (500/page x 20 pages max). To traverse larger result sets, use
KalturaESearchRangeoncreated_atwith scroll-forward pagination — move the date window after each 10K batch. - Large Result Sets: Always use the
pagerparameter (pageIndex,pageSize) to retrieve results in manageable chunks. Iterate through pages by incrementingpageIndexuntil the number of returned objects is less thanpageSizeor zero. - Highlighting Context: Remember that highlights (
<em>tags) are embedded in the text. You might need to parse or display this HTML carefully. TheitemsDataarray provides more context for matches in captions or metadata than the top-levelhighlightarray. - Partial vs. Exact Match:
PARTIAL(itemType=2) is powerful due to synonyms but might return less precise results thanEXACT_MATCH(itemType=1). Choose based on the desired recall vs. precision. UseignoreSynonym=trueinsearchParamsto disable synonym expansion if needed. - NOT Operator Shorthand: Use the
!prefix infreeText(e.g.,searchTerm=!excluded) to exclude matches. For structured queries, useKalturaESearchOperatorTypewithNOT_OP(3). - Performance: Unified searches (
KalturaESearchUnifiedItem) are convenient but can be slower than targeted searches using specificfieldNames (likeNAMEorCAPTIONS_CONTENT) because they query more fields. Optimize by specifying fields when possible. - Abstract vs. Concrete Types: Several Kaltura object types are abstract base classes that cannot be used directly in API calls. Using an abstract type returns
OBJECT_TYPE_ABSTRACT. FororderBy, useKalturaESearchEntryOrderByItem(notKalturaESearchOrderByItem). For aggregations, useKalturaESearchEntryAggregationItem(notKalturaESearchAggregationItem). Each search action (entry, category, user, group) has its own concrete types. - Aggregation Path Nesting: The aggregations parameter has double nesting:
searchParams[aggregations][aggregations][0]. The outeraggregationsis theKalturaESearchAggregationcontainer object; the inneraggregationsis the array property holding the items. UsingsearchParams[aggregations][0](single level) silently returns no aggregations. - Caption Timestamps Are Milliseconds:
startsAtandendsAtinKalturaESearchCaptionItemDataare integers in milliseconds (e.g.,16700= 16.7 seconds). Divide by 1000 for seconds. - JSON Body Support: The API v3 backend accepts both
application/x-www-form-urlencoded(bracket notation) andapplication/json(nested objects) with identical results. JSON is easier for programmatic construction and SDK integration. - Schema Reference: The Kaltura API schema (XML) is the definitive source for all object structures, properties, enums, and their exact names. Refer to it frequently.