Hi, Shiv:

> I need to search for empty values for a given key

You might need to use a cts.query()  constructor instead of QBE for this kind 
of query.

Given this test document:

    xdmp.documentInsert('/test/testdoc.json', {test1:"value", test2:null, 
test3:""});

If "empty" means null, you can use:

    jsearch.documents().where(cts.jsonPropertyValueQuery('test2', 
null)).result();

If "empty" means an empty string, you can use:

    jsearch.documents().where(cts.jsonPropertyValueQuery('test3', "")).result();

If "empty" means the absence of a property, you can use:

    jsearch.documents().where(cts.notQuery(cts.jsonPropertyScopeQuery('test4', 
cts.trueQuery()))).result();


Hoping that helpsl,


Erik Hennum


________________________________
From: general-boun...@developer.marklogic.com 
[general-boun...@developer.marklogic.com] on behalf of Shiv Shankar 
[shiv.shivshan...@gmail.com]
Sent: Tuesday, December 20, 2016 10:13 AM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] Search for empty falues

Hi,
I need to search for empty values for a given key, Tried below, but resulted 
nothing. I see values with empty in the collection. Any advice?

jsearch.documents().where(jsearch.byExample({EMP_ID: ""})).result();

Thanks
Shan.
_______________________________________________
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to