title: MarkLogic: search for word in any element apart from specified one(s)
body: <p>How can I write a cts:query that efficiently searches for documents that contain a certain word, unless that word only occurs in a certain element.</p>
  
  <p>For example, I want to return documents containing the word "dog" but only if it's in any element apart from &lt;title&gt;.</p>
  
  <p>So, given these documents:</p>
  
  <pre><code>&lt;document id="doc-1"&gt;
   &lt;heading&gt;foo&lt;/heading&gt;
   &lt;paragraph&gt;foo foo foo&lt;/paragraph&gt;
  &lt;/document&gt;
  
  &lt;document id="doc-2"&gt;
   &lt;heading&gt;bar dog&lt;/heading&gt;
   &lt;paragraph&gt;bar bar bar&lt;/paragraph&gt;
  &lt;/document&gt;
  
  &lt;document id="doc-3"&gt;
   &lt;heading&gt;foo dog&lt;/heading&gt;
   &lt;paragraph&gt;dog bar bar&lt;/paragraph&gt;
  &lt;/document&gt;
  </code></pre>
  
  <p>I want doc 3 returned.</p>
  
  <p>This works:</p>
  
  <pre><code>for $i in $doc-set
           where( doc($i)//*/text()[contains(normalize-space(lower-case(.)), "dog")] 
               [not(parent::title)] )
  
  return $i ;
  </code></pre>
  
  <p>but it's very slow</p>