Skip to main content

Administrating MarkLogic Server

Examples of Index Path Expressions

The following table provides examples of XPath expressions that are valid and invalid for defining a path range index.

Note

Avoid creating multiple path indexes that end with the same element/attribute, as ingestion performance degrades with the number of path indexes that end in common element/attributes.

Valid

Invalid

//a

./a

/a/b/c

/a/b[c=/p/q]

/a/b[c]

/a/b[c=5+3]

/a/b[c=5 and b=3]

/a/b[1]

//a/b[c<5]

//a/b[c="test"]

/a/*/c

a/b

/a[./b]/c

/a[/b]/c

a

/a/(b|c)

/a/(/b|/c)

(/a/b/c)[2]

author[first-name="John"][last-name="Smith"]

author[first-name="John" and last-name="Smith"]

author[first-name="John" or first-name="Sam"]

/a/b[.//c]

/a/b[c]

/a/b/[./c]

/a/b[//c]

/a/b/[/a/b/c]

/a/(./b | c)/d

/a/(/a/b | /a/c)/d

/a/child::*/b

/a/parent::*/b

/a[fn:matches(@expr, 'is')]

/a/[fn:matches(fn:name(.),"Joe")]

/a/fn:contains("this")

/a/[fn:contains(fn:name(.),"Bob")]

Namespace prefixes are permitted in all valid path expressions. Note that you can also use fn:matches and fn:contains as part of the path expression, but you cannot use other functions in the path expression. Use cts:valid-index-path to test if a path expression is valid for an index path.