What does the a JSON blob with search filters, allowed operators: $eq, $ne, $in, $nin, $gt, $lt, $gte, $lte, $exists
in the Swagger documentation that is shown in the DataStax Document API Swagger UI, it's not that documented so I want to ask if the query string is based on MongoDB?
DataStax Stargate Document API
206 views Asked by quarks At
2
There are 2 answers
0
On
The query string is pretty similar in spirit to what you'd find with Mongo.
Here are some sample where clauses to give an idea:
{"name": {"$eq": "Eric"}}
- simple enough, matches documents that have a field name
with value Eric
{"a.age": {"$gt": 0}}
- You can also reference nested fields in a document
{"friends.[0].name": {"$in": ["Cassandra"]}}
- Array elements are referenced using []
, this would match if the document's first friend is named Cassandra.
{"friends.*.age": {"$gte": 24}}
- Wildcard *
can be used to match any element in an array, or any field at a particular level of nesting. This matches any friend whose age is >= 24.
The Document API exposed on top of Cassandra is provided by the open source project Stargate, indeed developed by Datastax and embedded in their Saas solution Astra.
The JSON query String than you created is parsed and converted in a proper CQL query under the hood.
Source code doesn't lie you can find the full code here and specially parsing of the where clause here