Optimized XPath formulas

Fast-index data is stored in an efficient format in memory. To be used in an XPath, the values need to be converted into a different format. Converting formats can take extra time. To avoid this overhead, certain XPath operations have been modified to directly interact with this format.

Comparison operators can be used in Watson™ Explorer Engine queries as long as the fields that are being referenced by those queries have been fast-indexed in the Watson Explorer Engine search application. See Fast-Indexing in the Watson Explorer Engine documentation for more information.

If a field has been fast-indexed as a number or date, and defined as a field in the syntax, the following comparison operators can be used: <, <=, >, >=, ==, and [..]. If a field has been fast-indexed as a set or string, use the comparison operator ==.

Note: The comparison operator == should not be used for floating point numbers, this is because floating point math is not exact and even simple numbers (such as 0.2) cannot be precisely represented using IEEE floating point numbers.

The following examples require only the default search form: and year defined as a field in the syntax:

  • If you have fast-indexed a content element named year as an int and have year defined as a field in the syntax, the Watson Explorer Engine standard search form and comparison operator support enables you to use that field for advanced queries, such as the following:
    year:> 1984
      year:[1960..1985]
    Note: The query year:[1960..1985] is not guaranteed to be the same as the query year: >= 1960 AND year: <= 1985 because a single document can have multiple fast-indexed content elements named year (e.g. one 1990 and one 1950), which would satisfy the open ended > AND and < queries but fall outside the explicit [1960..1985] range.
  • If you have fast-indexed a content element named date and have date defined as a field in the syntax, the Watson Explorer Engine standard search form and comparison operator support enables you to use that field for advanced queries such as the following:
    date:> "2009-01-10"
      date:<= "2009-01-10"
      date:== "2009-01-10"
      date:[2009-01-10..2010-02-20]

    The string is processed with the viv:parse-date function.

  • If you have fast-indexed a content element named hero as a set and have hero defined as a field in the syntax, comparisons are exact, including capitalization and punctuation. For example, the following examples are all different queries:
    
      hero:=="SID HALLEY"
      hero:=="Sid Halley"
      hero:=="sid halley"