Search code examples
mongodbcassandradatastaxstargate-oss

DataStax Stargate Document API


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?


Solution

  • 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

    public List<FilterCondition> convertToFilterOps(
     List<PathSegment> prependedPath, 
     JsonNode filterJson) {
     
     List<FilterCondition> conditions = new ArrayList<>();
    
     if (!filterJson.isObject()) {
      throw new DocumentAPIRequestException("Search was expecting a JSON object as input.");
     }
    
     ObjectNode input = (ObjectNode) filterJson;
     Iterator<String> fields = input.fieldNames();
     while (fields.hasNext()) {
      String fieldName = fields.next();
      if (fieldName.isEmpty()) {
        throw new DocumentAPIRequestException(
            "The field(s) you are searching for can't be the empty string!");
      }
     ...