简体   繁体   English

Marklogic中的非Null值-搜索JSON文档,其数组中的属性在Marklogic中具有非空值

[英]Non Null values in Marklogic - Search JSON documents with attributes in array with not null values in Marklogic

Structure of JSON documents required to be searched in Marklogic 需要在Marklogic中搜索的JSON文档的结构

{  
   "MESSAGEID":"18878285",
   "ORDERNUMBER":["2295796"],
   "CATEGORY":"F3702200000"
}

I wanted to search the URIs of all JSON documents in Marklogic that comprised of not null ORDERNUMBER using Javascript 我想使用Javascript搜索Marklogic中所有包含非空ORDERNUMBER JSON文档的URI

I am using the following query but it is still showing the URIs for the documents comprising of "ORDERNUMBER":[] 我正在使用以下查询,但仍显示包含"ORDERNUMBER":[]的文档的URI "ORDERNUMBER":[]

cts.uris("",null,cts.andQuery
    ([
        cts.jsonPropertyValueQuery("ORDERNUMBER", "*", "wildcarded"),
        cts.notQuery(cts.jsonPropertyValueQuery("ORDERNUMBER",""))
    ])
);

You normally have a few options, but the empty array case is particularly hard to distinguish. 通常,您有几种选择,但是空数组的情况尤其难以区分。 This is because it is neither an empty string value, nor a null, yet the property is truly present. 这是因为它既不是空字符串值也不是null,但是该属性确实存在。

cts.jsonPropertyScopeQuery("ORDERNUMBER", cts.trueQuery()) will match any doc that has that property. cts.jsonPropertyScopeQuery("ORDERNUMBER", cts.trueQuery())将匹配具有该属性的任何文档。

cts.jsonPropertyValueQuery("ORDERNUMBER", "") matches ORDERNUMBER: "" and ORDERNUMBER: [""] . cts.jsonPropertyValueQuery("ORDERNUMBER", "")匹配ORDERNUMBER: ""ORDERNUMBER: [""]

cts.jsonPropertyValueQuery("ORDERNUMBER", null) matches ORDERNUMBER: null . cts.jsonPropertyValueQuery("ORDERNUMBER", null)匹配ORDERNUMBER: null

cts.jsonPropertyValueQuery("ORDERNUMBER", "?*", "wildcarded") matches ORDERNUMBER: null (not sure why), ORDERNUMBER: "xx" , and ORDERNUMBER: ["xx"] , but only if you enable filtering (which requires cts.search ), or if you are able to find the appropriate wildcard settings. cts.jsonPropertyValueQuery("ORDERNUMBER", "?*", "wildcarded")匹配ORDERNUMBER: null (不确定原因), ORDERNUMBER: "xx"ORDERNUMBER: ["xx"] ,但ORDERNUMBER: ["xx"]是您启用了过滤(需要cts.search ),或者是否能够找到适当的通配符设置。

To be honest, the simplest solution to my opinion is to just put a range index on ORDERNUMBER , and use a rangeQuery: 老实说,我认为最简单的解决方案是将范围索引放在ORDERNUMBER ,并使用rangeQuery:

cts.rangeQuery(cts.pathReference('ORDERNUMBER'), '>', '')

HTH! HTH!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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