Loading TOC...

cts.jsonPropertyScopeQuery

cts.jsonPropertyScopeQuery(
   $property-name as String[],
   $query as cts.query
) as cts.jsonPropertyScopeQuery

Summary

Returns a cts:query matching JSON properties by name with the content constrained by the given cts:query in the second parameter. Searches for matches in the specified property and all of its descendants.

Parameters
$property-name One or more property names to match. When multiple names are specified, the query matches if any name matches.
$query A query for the property to match. If a string is entered, the string is treated as a cts:word-query of the specified string.

Usage Notes

Enabling both the word position and element word position indexes will speed up query performance for many queries that use cts:json-property-scope-query. The position indexes enable MarkLogic Server to eliminate many false-positive results, which can reduce disk I/O and processing, thereby speeding the performance of many queries. The amount of benefit will vary depending on your data.

Example

// Given a database that has a JSON document as follows:
//  {"a":"aa","new":["array","content"],"b":["aa","bb"]}

cts.search(cts.jsonPropertyScopeQuery( 'a', 'aa'))

// Returns a relevance-ordered sequence of JSON documents (including
// the above document) with a property named "a" having a
// value of "aa".

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.

Comments

  • Hello, I'm trying to filter all documents which don't have a specified property. JSON example: {... "plv2": { "dateOfMeeting": "2018-02-01T00:00:00.000", "supervisorName": "Stefan Doi", "plVPeriod": { "startDate": "2017-12-02T00:00:00", "endDate": "2018-03-31T00:00:00" }, "documents": [ "1c8e2d1c-8829-49f1-9de7-84f648cfd68a" ] }, "plv3": { "dateOfMeeting": "2018-04-01T00:00:00.000", "supervisorName": "Stefan Trei", "plVPeriod": { "startDate": "2018-04-02T00:00:00", "endDate": "2018-08-31T00:00:00" } } ...} This is the query I've used(specific for plv3 subsobject): cts.jsonPropertyScopeQuery("plv3", cts.notQuery(cts.jsonPropertyWordQuery("documents", "*"))) I'm trying to retrieve the documents which don't have under "plv3" field "documents" array. To be mentioned that it works if we check the existence ( cts.jsonPropertyScopeQuery("plv3", cts.jsonPropertyWordQuery("documents", "*")) ) Regards, Stefan
    • Hello, I noticed that this issue hasn't been addressed here. I recommend that you ask this on Stack Overflow https://stackoverflow.com/questions/tagged/marklogic where it will reach a wider audience, as well as others who may have the same question.