MarkLogic: using cts: finding elements without text

I want to find all documents that have no text inside a specific element - this works, but very slowly:

let $not-empty := for $i in cts:search(//foo[@class="bar"][text()[not(. = '')]] ,
                                  cts:and-query(())
                                    ) 
                                 return base-uri($i)

how to effectively use indexes to search for elements without node text and where node text contains no characters?

+4
source share
1 answer

Search will work faster with a simpler search path and more complex query. I think this is the closest that you can use cts functions:

cts:search(
  //foo,
  cts:and-query((
    cts:element-attribute-value-query(xs:QName('foo'), xs:QName('class'), 'bar'),
    cts:element-value-query(xs:QName('foo'), '')
  ))
)

NTN!

+4
source

All Articles