[MarkLogic Dev General] Search API: specifying multiple constraints
karl.erisman at gmail.com
Sun Nov 22 17:51:44 PST 2009
Suppose an XML structure has repeated element names, for example:
How can the search API be used to find a *specific* <phone> element,
ignoring other such elements at different levels (XPath:
contacts/contact[name/text()="bob"]/phone)? The following:
name="relation"><value><element ns="" name="relation"
...would allow matches for <relation> *anywhere* in the document (as
long as the cts:element-value-query implied by the constraint option
is satisfied). However, I want the constraint to allow a match for
Uncle Bob, but not Uncle Mike (so if the above XML was in two separate
documents, only one would match).
Of course, my target documents will be much more interesting, but this
illustrates the pattern. I'm interested in knowing how to require
that matches satisfy more complicated constraints than "element is x",
"attribute is y", etc.
I also would like to know how to require that matches follow a
particular path which may involve many hierarchical levels (so I can
be sure that results come from a specific subtree and not another
subtree that may use the same element names). Perhaps it depends on
the specific situation, but are <additional-query> and <custom> the
best facilities for tasks such as these? That would still make for
lots of manual cts:query construction work.
More information about the General