15.07.2016 Views

MARKLOGIC SERVER

Inside-MarkLogic-Server

Inside-MarkLogic-Server

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

MORE WITH FIELDS<br />

Fields also provide a way to create singular indexed values out of complex XML.<br />

Imagine that you have XML structured like this:<br />

<br />

John<br />

Fitzgerald<br />

Kennedy<br />

<br />

You can create a field named "fullname" against defined to contain all of its<br />

child elements. Its singular value will be the person's full name as a string. You can<br />

create another field named "simplename" against but excluding . Its<br />

singular value will be just the first and last names as a string. Using cts:field-valuequery()<br />

you can do optimized queries against either of these computed values. It's<br />

much faster than computing values as part of the query. Within the Universal Index,<br />

each field simply adds term lists, one for each value.<br />

As mentioned previously, you can even create a range index against a field. Then you<br />

can sort by, constrain by, and extract values not even directly present in the documents.<br />

REGISTERED QUERIES<br />

Registered queries are another performance optimization. They allow you to register<br />

a cts:query as something you plan to use repeatedly and whose results you'd like<br />

MarkLogic to remember for later use.<br />

Let's say that you're going to generate a report on the number of Firefox browsers per<br />

day that hit any index.html page on your site. You may want to register the portion of the<br />

query that doesn't include the day, then use it repeatedly by intersecting it with the<br />

day constraint.<br />

For the code below, let's assume that we have a set of documents in the fact<br />

namespace that records data about visiting browsers: their name, version, and<br />

various attributes, and the session ID in which they appear. You can think of those<br />

documents as the XML equivalent of a fact table. Let's assume that we also have a set<br />

of documents in the dim namespace (the XML equivalent of a dimension table) that<br />

records data about particular page hits: the page they hit, the date on which they were<br />

seen, and other aspects of the request, such as its recorded performance characteristics.<br />

77

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!