Rewrite xpath code in cts:search()

Hi Mariano,



If you search for “*”, then you ask for values with that exist. Try
replacing it with section value-query by an element-query with
cts:and-query(()) as sub-query..



Kind regards,

Geert



*Van:* [email protected] [mailto:
[email protected]] *Namens *Mariano Grau Calín
*Verzonden:* dinsdag 12 november 2013 9:52
*Aan:* [email protected]
*Onderwerp:* [MarkLogic Dev General] Rewrite xpath code in cts:search()



Hi all.

Given this two documents:

  <doc>
    <published>
      <pub>madrid</pub>
    </published>
  </doc>

  <doc>
    <published>
      <pub>madrid</pub>
      <section>sport</section>
    </published>
    <published>
      <pub>london</pub>
    </published>
  </doc>

This code returns document #2:

doc()/doc/published[pub='london' and not(section)]

If i run the next cts:search() code:

cts:search(/doc,
  cts:element-query(xs:QName("published"),
    cts:and-query((
      cts:element-value-query(xs:QName("pub"), "london")
      ,cts:not-query(cts:element-value-query(xs:QName("section"), "*" ))))
    )
)

Get 'your query returned an empty sequence'.
However, if change 'london' by 'madrid' get document #1.

The target is to search documents where published-node contain pub-node and
not section-node.

Thanks,

Mariano Grau
Dpto. Sistemas
Grupo Joly
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to