I wanted to search documents based on one of it's property using rest api in marklogic. Here is the document -
{
"id" : "101",
"sectionName" : "PI"
"firstName" : "I",
"middle name" : "Me",
"last name : "Myself",
"emailId" : "[email protected]"
}
Lets say, i want to search documents based on sectionName and order by id then what will be my rest query?
If you want to order by id, you must first create a range index on id in the Admin UI.
Then, you can submit a search request with the sectionName as criteria and the id for sort order:
Something along the following lines should work:
{"search":{
"query":{"queries":[{
"value-query":{
"json-property":"sectionName",
"text":["PI"],
"term-option":["exact"]
}
}]},
"options":{
{"sort-order":{"json-property":"id"}}
}
}}
Hoping that helps,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With