I have been using cts:search
with searchable-expression to extract specific elements from XML documents. For example:
Document:
<book>
<recipe>
<ingredients>cinnamon, peppermint</ingredients>
<instruction/>
</recipe>
<recipe>
<ingredients>sugar, peppermint</ingredients>
<instruction/>
</recipe>
<recipe>
<ingredients>coconut oil</ingredients>
<instruction/>
</recipe>
</book>
Query:
cts:search(//recipe, cts:parse("peppermint"))
Results:
<recipe>
<ingredients>cinnamon, peppermint</ingredients>
<instruction>
</instruction>
</recipe>
<recipe>
<ingredients>sugar, peppermint</ingredients>
<instruction>
</instruction>
</recipe>
However, this doesn't work with cts:not-query
and no result is returned for the following search:
cts:search(//recipe, cts:parse("-cinnamon"))
Looking into the query plan, my understanding is that the cts:not-query
is applied at the fragment (document) level prior to filtering so the above document is eliminated outright. If that is correct, this behavior makes sense.
Nevertheless I am still wondering if this can be accomplished somehow. Thanks!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…