Query-Limited Facets

Earlier we mentioned a fifth argument to cts:element-attribute-values(). The fifth argument is a cts:query object that limits the returned results to those taken from documents matching the given cts:query. The following finds the top senders of mails matching a specific query.

We're extracting values from the from/@personal attributes, which holds the human-readable names of senders. We start at "" (the beginning), ask for results in frequency order (so the most common occurrances are first), and limit results to the $query. We then print the value and count for the top 100. These are the folks from Apache and Firefox who talk a lot about releases.

We can also extract message/@year-month and sort by value (value is the default) and what we'll see is a traffic-by-month report, the basis for the MarkMail histogram chart:

We've now seen almost all the building blocks of MarkMail.org. But how do we take the user's typed string in the search box and convert it to cts:query objects? For that we can use the Search API.

Functions

The Search API

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.