Henry
Henry

Reputation: 37

MarkLogic cts.elementQuery using xs.QName not returning results

I have a simple query in JavaScript:

cts.search(
    cts.elementQuery(xs.QName("headline"), "NYSE")
)

And here is one of the files in the database:

<?xml  version="1.0" encoding="UTF-8"?>
<ContentEnvelope majVers="1" minVers="0.7" pubStyle="Message" xmlns="http://data.schemas.tfn.thomson.com/Envelope/2008-05-01/" xmlns:news="http://news.schemas.tfn.thomson.com/2008-05-01/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Header>
        <Info>
            <Id>20151009-194502000-nZHN0BKF21-1-2</Id>
            <TimeStamp>2015-10-09T19:45:03.228Z</TimeStamp>
        </Info>
    </Header>
    <Body contentSet="News" majVers="1" minVers="3.0">
        <ContentItem action="Insert">
            <Entitlements/>
            <Data xsi:type="news:NewsDataItem">
                <newsItem standard="NewsML-G2" standardversion="2.7" conformance="power" guid="20151009-194502000-nZHN0BKF21-1-2" version="1" xml:lang="en" xsi:schemaLocation="http://iptc.org/std/nar/2006-10-01/ NAR_1.8-spec-All-Power_2.xsd http://www.w3.org/1999/xhtml xhtml1-strict.xsd" xmlns="http://iptc.org/std/nar/2006-10-01/" xmlns:rtr="http://www.reuters.com/ns/2003/08/content" xmlns:x="http://www.w3.org/1999/xhtml">
                    <catalogRef/>
                    <itemMeta/>
                    <contentMeta>
                        <urgency>3</urgency>
                        <altId type="idType:USN" rtr:isOriginal="1">nZHN0BKF21</altId>
                        <language tag="en">
                        </language>
                        <subject qcode="N2:US">
                        </subject>
                        <headline>NYSE ORDER IMBALANCE <EMC.N> 205600 SHARES ON BUY SIDE</headline>
                    </contentMeta>
                    <contentSet/>
                </newsItem>
            </Data>
        </ContentItem>
    </Body>
</ContentEnvelope>

I am getting an empty response.

Upvotes: 3

Views: 328

Answers (1)

Ankit Bhardwaj
Ankit Bhardwaj

Reputation: 774

You are missing namespace declaration in the query. Try using this query -

cts.search(
    cts.elementQuery(fn.QName("http://iptc.org/std/nar/2006-10-01/", "headline"), "NYSE")
)

Upvotes: 2

Related Questions