The MEL syntax lets you handle categories, facets and entries to return values. You can access these in both:
• an absolute way, for example, in a custom HTML widget;
• and a relative way, within a specific context set by the widget, for example, in a chart widget that requires the setting of a facet.
About Relative access in a given context
When manipulating MEL, you are in a given context. For example, in widgets, you are most of the time in a ''feed'' context, so you don't need to give the beginning of the context in your MEL expression as the widget already has set the context for you.
In the contextual menu listing all available Values on the left, select elements from Contextual feed to add them in a "feed" context in your MEL expression.
For example, a Result List widget iterates over each entry (hit) for each feed, so you can use the relative access to the entries meta as you are scoped at the ''entry'' level. In MEL, this is written as ${entry.***} rather than ${page.feed.entry} as written in an absolute way.
The following diagram represents a tree view of the MEL relative context.
Note: You can enter at any level in the context, but you cannot skip sub-context elements.
Sample data
The following data will be used to illustrate the use of the MEL syntax for facet aggregation.
This section shows the syntax for accessing global information regarding the result set.
• Access to result set infos
◦ Syntax: ${feed.infos["resultSetInfo"]}
◦ Example: ${feed.infos["nhits"]} --> 1
Available attributes
resultSetInfo are directly mapped to the Access API. They can be one of the following:
• id
• totalResults
• startIndex
• itemsPerPage
• query
• context
• last
• start
• estimated
• nhits
• autocorrected
• ellql
• nmatches
• unknown parameter provided by a specific feed
Feed access
• Access to parent parameters in a subfeed
◦ Syntax: ${feed.entries[2].subfeeds["subfeedname"].entries[0].metas["title"] --> Title of the subfeed’s first entry of the parent feed’s third entry.
Request, Cookie and Session MEL Manipulation
• request gathers all the parameters of the HTTP request.
◦ ${request["contextPath"]}
◦ ${request["queryString"]}
• cookies gathers all the parameters available in the Mashup UI cookies.
◦ ${cookies["name"]}
• session gathers all the parameters available in the user session.
◦ ${session["username"]}
◦ ${session["name"]}
Use cases
The following examples show typical uses of facet manipulations.
Create a metric-like widget
You can create a metric-like widget using an HTML widget with custom HTML code. MEL allows the widget to interact with facets and calculate aggregations values. In the following example, the HTML code retrieves facet descriptions and aggregations to display average values in a dashboard.
The HTML widget should display results as shown in the following screenshot.
Format standard facet values
The Standard Facets widget can display categories and facets with an aggregation function.
You can interact with the facet of a category that is defined in the widget.
Iterate over facets in an HTML widget
Iterate over facets in anHTML widget
You can iterate over facets in an HTML widget using custom MEL. For example, you can iterate on a category/ facet to replicate the Standard Facets widget behavior.