Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
constraint (term lists are of no use) and will examine all books with any <br />
elements. The performance difference can be dramatic.<br />
Birthday (Value) Person (Document) Person (Document) Birthday (Value)<br />
1946-02-12<br />
1953-02-04<br />
1955-09-15<br />
1958-05-15<br />
1963-05-19<br />
1964-03-25<br />
1965-05-05<br />
1966-04-21<br />
1972-08-14<br />
1978-06-02<br />
1988-03-04<br />
1978-06-02<br />
1946-02-12<br />
1955-09-15<br />
1965-05-05<br />
1966-04-21<br />
1992-06-16<br />
1972-08-14<br />
1988-03-04<br />
1958-05-15<br />
1953-02-04<br />
1964-03-25<br />
1992-06-16 1963-05-19<br />
Figure 4: Conceptually, range indexes are implemented with two data structures. One is an array of<br />
values and document IDs, sorted by value. The other is an array of document IDs and values, sorted by<br />
document ID. You can use the structures to quickly look up documents associated with a value range (1)<br />
as well as individual values associated with one or more documents (2).<br />
DATA-TYPE-AWARE EQUALITY QUERIES<br />
The same "value to document ID" lookup array can support equality queries that<br />
have to be data-type aware. Imagine that you're tracking not just the birthday but the<br />
exact time when every person was born. The challenge is that there are numerous<br />
ways to serialize the same timestamp value, due to trailing time zone decorations. The<br />
timestamps 2013-04-03T00:14:25Z and 2013-04-02T17:14:25-07:00 are<br />
semantically identical. It's the same with the numbers 1.5 and 1.50. If all of your<br />
values are serialized the exact same way, you can use a term list index to match the<br />
string representation. If the serialization can vary, however, it's best to use a range index<br />
because those are based on the underlying data-type value (but instead of specifying a<br />
range to match, you specify a singular value).<br />
To perform a data-type-aware equality query, you can use cts:element-rangequery()<br />
with the "=" operator, or you can use XPath and XQuery. Consider the<br />
XPath mentioned earlier, /book[metadata/pubyear = 2013]. Because 2013 is an<br />
integer value, if there's a range index on of a type castable as an integer, it<br />
will be used to resolve this query.<br />
Note that for numeric and Boolean values in JSON documents, you can perform<br />
equality comparisons without a range index since those data types are indexed in typespecific<br />
indexes (see the section "Indexing JSON" for details). However, you still need<br />
range indexes for inequality comparisons.<br />
29