简体   繁体   中英

MarkLogic: using cts:search to find elements without text

I want to find all documents that don't have any text within a certain element - this works but is very slow:

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

how can I use the indexes effectively to search for elements without a text node and where the text node doesn't contain any characters?

The search will run faster with a simpler searchable path, and a more complex query. I think this is the closest you can get using 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'), '')
  ))
)

HTH!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM