thichxai
thichxai

Reputation: 1133

Marklogic cts:element-value-query Or condition match

doc1.xml

<note>COGNITIVE SCIENCE, EXPERIMENTAL DESIGN</note>

doc2.xml

<note> EXPERIMENTAL DESIGN, AI PROGRAMMING LANGUAGE, JAVA Online</note>

How can I construct a query to return documents that have condition COGNITIVE SCIENCE "OR" Java Online. I use cts:element-value-query() but don't know how to add "OR" condition.

cts:uris(
    (),
    ("descending"),
    cts:and-query((
            cts:collection-query(("/courses")),
            cts:element-value-query(
                                    xs:QName("note"),"COGNITIVE   SCIENCE","case-insensitive")


    ))
)

Thanks in advance Thichxai

Upvotes: 1

Views: 299

Answers (2)

mholstege
mholstege

Reputation: 4912

You can give a list of phrases to cts:element-value-query:

cts:element-value-query(xs:QName("note"),("COGNITIVE SCIENCE","Java Online"), "case-insensitive")

Upvotes: 3

Sam Mefford
Sam Mefford

Reputation: 2475

cts:uris(
    (),
    ("descending"),
    cts:and-query((
      cts:collection-query(("/courses")),
      cts:or-query((
        cts:word-query("COGNITIVE SCIENCE","case-insensitive"),
        cts:word-query("Java Online","case-insensitive")
      ))
    ))
)

Upvotes: 1

Related Questions