Reputation: 207
I have been trying to find the documents from a particular collection based on the field report_time.
I have been trying the below query. But, it doesn't work.
cts.andQuery(cts.collectionQuery('myCollection'),cts.jsonPropertyRangeQuery("report_time", ">", new Date(Date.now() - 86400 * 1000).toISOString()))
Upvotes: 0
Views: 73
Reputation: 321
You don't have to do the math, you can use an "age query". See the end of the page at https://docs.marklogic.com/guide/search-dev/rangequery
Upvotes: 0
Reputation: 66781
From that snippet, the one thing that needs adjustment is that the query criteria need to be in an array for the cts.andQuery()
param:
cts.andQuery([
cts.collectionQuery('myCollection'),
cts.jsonPropertyRangeQuery("report_time", ">", new Date(Date.now() - 86400 * 1000).toISOString())
])
Upvotes: 1