{"id":807,"date":"2017-08-16T20:20:11","date_gmt":"2017-08-16T20:20:11","guid":{"rendered":"http:\/\/live.ecd-demo.com\/apihelp\/?page_id=807"},"modified":"2017-08-16T20:20:11","modified_gmt":"2017-08-16T20:20:11","slug":"filters","status":"publish","type":"page","link":"https:\/\/apihelp.ecd-demo.com\/index.php\/documentation\/what-does-the-api-contain\/filters\/","title":{"rendered":"Filters"},"content":{"rendered":"\nBesides Search, this is the main functionality of ECDAPI. It returns metadata of the documents matching the filter criteria. The candidate documents are those in the given store or in all active stores of the given store type \/ hierarchy level.\n\n\n\n<br>Please note that for performance reasons there is a hard-coded internal limit of 10000 results (including pagination). Huge result sets shall be retrieved by splitting them into subsets via filtering (e.g. by source or by time).\n\n\n\n\n<h3 class=\"wp-block-heading\">CONSTRUCTING A FILTER<\/h3>\n\n\n\n\nA filter is constructed as follows:\n\n\n\n\n<pre class=\"wp-block-code\"><code>{\n    \"term\": string,\n    \"operator\": enum,\n    \"value\": string\n}\n<\/code><\/pre>\n\n\n\n\n\n<ul class=\"wp-block-list\"><li><code>term<\/code> defines the document attribute in dot notation<\/li><li><code>operator<\/code> is one of \u201c<code>equals<\/code>\u201d, \u201c<code>notEquals<\/code>\u201d, \u201c<code>atMost<\/code>\u201d, \u201c<code>atLeast<\/code>\u201d, \u201c<code>smaller<\/code>\u201d, \u201c<code>larger<\/code>\u201d, \u201c<code>exists<\/code>\u201d or \u201c<code>notExists<\/code>\u201d, the default value is \u201c<code>equals<\/code>\u201d<\/li><li><code>value<\/code> the value of the document attribute<\/li><\/ul>\n\n\n\n\nExample: Get all events of a series by ID\n\n\n\n\n<pre class=\"wp-block-code\"><code>GET http:\/\/&lt;api-url>\/stores-active\/contentInstance\/event\/filter?filter={\"term\":\"internalIds.seriesId\",\"value\":\"105739158\"}\n<\/code><\/pre>\n\n\n\n\nThere is a special case for the operator \u201c<code>in<\/code>\u201d where the filter expects a list of <code>\u201cvalues\u201d:[string]<\/code> that the attribute specified by term has to match.\n\n\n\nExample: Get events on channels ITV2 and ITV3\n\n\n\n\n<pre class=\"wp-block-code\"><code>GET http:\/\/&lt;api-url>\/stores-active\/contentInstance\/event\/filter?filter={\"term\":\"source\",\"operator\":\"in\",\"values\":&#91;\"ITV2\",\"ITV3\"]}\n<\/code><\/pre>\n\n\n\n\nYou can combine filters using operator \u201c<code>and<\/code>\u201d, \u201c<code>or<\/code>\u201d or \u201c<code>nestedAnd<\/code>\u201d:\n\n\n\n\n<pre class=\"wp-block-code\"><code>{\n    \"operator\": enum ,\n    \"criteria\": &#91;@genericFilter]\n}\n<\/code><\/pre>\n\n\n\n\nExample: Get events that have keyword of value talkshow\n\n\n\n\n<pre class=\"wp-block-code\"><code>GET http:\/\/&lt;api-url>\/stores-active\/contentInstance\/event\/filter?filter={\"operator\":\"nestedAnd\",\"criteria\":&#91;{\"term\":\"tags.category.categoryId\",\"value\":\"Keyword\"},{\"term\":\"tags.value.valueId\",\"value\":\"talkshow\"}]}\n<\/code><\/pre>\n\n\n\n\n\n<h4 class=\"wp-block-heading\">WINDOW OF AVAILABILTY FILTERING<\/h4>\n\n\n\n\nA special type of often used filtering is by scheduledStart- and End- DateTime\n\n\n\n<strong>Absolute windows<\/strong> can be defined by providing timestamps for the start and end of the window:<br><code>\"windowOfAvailabilityStart\": timestamp<\/code><br><code>\"windowOfAvailabilityEnd\": timestamp<\/code>\n\n\n\nExample: Get events broadcast between 5AM UTC on June 21st and 5AM on June 22nd on channels ITV 2 and ITV3\n\n\n\n\n<pre class=\"wp-block-code\"><code>GET http:\/\/&lt;api-url>\/stores-active\/contentInstance\/event\/filter?filter={\"term\":\"source\",\"operator\":\"in\", \"values\":&#91;\"ITV2\",\"ITV3\"]}&amp;windowOfAvailabilityStart=2016-06-21T05:00:00Z&amp;windowOfAvailabilityEnd=2016-06-22T05:00:00Z\n<\/code><\/pre>\n\n\n\n\n<strong>Relative windows<\/strong> can be defined by providing a relative time and an offset for the start and the end of the window where <code>origin<\/code> is either \u201c<code>currentTime<\/code>\u201d or \u201c<code>startOfDay<\/code>\u201d and \u201c<code>offset<\/code>\u201d a duration in XSD duration format. A \u201c<code>timeZone<\/code>\u201d: timezone, can optionally be provided to interpret relative window of availability origins.\n\n\n\nExample: Search for \u201cunscrupulous\u201d on events scheduled for the next 24 hours\n\n\n\n\n<pre class=\"wp-block-code\"><code>GET http:\/\/&lt;api-url>\/stores-active\/contentInstance\/event\/search?query=unscrupulous&amp;relativeWindowOfAvailabilityStart={\"origin\":\"currentTime\",\"offset\":\"PT0H\"}&amp;relativeWindowOfAvailabilityEnd={\"origin\":\"currentTime\",\"offset\":\"PT0H\"}\n<\/code><\/pre>\n\n\n\n\nWindows can have different types defining the interpretation of the windows of availability <code>windowOfAvailabilityType:<\/code> enum:\n\n\n\n<code>overlap:<\/code> any overlap between the asset\u2019s availability and the specified window of availability will be allowed<br><code>strictStart:<\/code> the start of the asset has to lie within the specified window of availability<br><code>strictEnd<\/code>: the end of the asset has to lie within the specified window of availability<br><code>strict<\/code>: both the start and end of the asset have to lie within the specified window\n\n\n\nThe default value is \u201c<code>overlap<\/code>\u201d.\n\n\n\n\n<h4 class=\"wp-block-heading\">NOW AND NEXT INFORMATION<\/h4>\n\n\n\n\nAnother special case of filtering is the \u201c<code>now<\/code> and <code>next<\/code>\u201d type request. A special keyword beforeAfter allows to return a number of documents available around the origin time.\n\n\n\n\n<ul class=\"wp-block-list\"><li><code>origin<\/code> may be an absolute timestamp or \u201c<code>currentTime<\/code>\u201d.<\/li><li><code>offset<\/code> points to the first document to be returned,<\/li><li><code>limit<\/code> defines the number of documents returned per source (typically per TV channel)<\/li><\/ul>\n\n\n\n\nExample: The following request retrieves now (<code>origin:currentTime, offset:0<\/code>) &amp; next (<code>limit:2<\/code>) information for all available channels:\n\n\n\n\n<pre class=\"wp-block-code\"><code>GET http:\/\/&lt;api-url>\/stores-active\/contentInstance\/event\/filter?beforeAfter={\"origin\":\"currentTime\",\"offset\":0,\"limit\":2}<\/code><\/pre>\n\n\n\n\n\n<h2 class=\"wp-block-heading\">Advanced Details<\/h2>\n\n\n\n\n\n<p class=\"has-medium-font-size\"><strong>Context merging rules<\/strong><br>If a contextId is provided together with an ad-hoc context, the two are merged according to the following rules:<\/p>\n\n\n\n\n\n<ul class=\"wp-block-list\"><li> the two contexts are merged at top level attribute level<\/li><li> if the ad-hoc and the pre-defined contexts both contain the same top-level attribute, the one in the ad-hoc context is kept<\/li><li> no merging at lower levels of the context object, in particular no merging of list attributes<\/li><\/ul>\n\n","protected":false},"excerpt":{"rendered":"<p>Besides Search, this is the main functionality of ECDAPI. It returns metadata of the documents matching the filter criteria. The candidate documents are those in the given store or in all active stores of the given store type \/ hierarchy level. Please note that for performance reasons there is a hard-coded internal limit of 10000 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":66,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-807","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/apihelp.ecd-demo.com\/index.php\/wp-json\/wp\/v2\/pages\/807","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/apihelp.ecd-demo.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/apihelp.ecd-demo.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/apihelp.ecd-demo.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/apihelp.ecd-demo.com\/index.php\/wp-json\/wp\/v2\/comments?post=807"}],"version-history":[{"count":0,"href":"https:\/\/apihelp.ecd-demo.com\/index.php\/wp-json\/wp\/v2\/pages\/807\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/apihelp.ecd-demo.com\/index.php\/wp-json\/wp\/v2\/pages\/66"}],"wp:attachment":[{"href":"https:\/\/apihelp.ecd-demo.com\/index.php\/wp-json\/wp\/v2\/media?parent=807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}