Giter Site home page Giter Site logo

rasata / docussandra Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tools-alexuser01/docussandra

0.0 2.0 0.0 3.83 MB

A REST API that behaves much like MongoDB, but with massive scale. Stores arbitrary payloads as BSON in Cassandra, supporting indexing, filtering, sorting, querying and pagination using limit and offset.

License: Apache License 2.0

Java 99.91% Shell 0.09%

docussandra's Introduction

Stories in Ready Build Status

#Docussandra: A REST-based, Document-Oriented Cassandra

Docussandra marries MongoDB's simple data storage model with the horizontal scaling of Cassandra. It enables developers to store arbitrary payloads as BSON, as they would with MongoDB, in a Cassandra cluster. It supports indexing, filtering, sorting, querying and pagination (via familiar limit and offset semantics). Simple json document storage with effortless scaling exposed as a service - that's Docussandra!

Five Minute Quick Start

Let's begin by starting a server and beginning to store data.

Prerequisites

A running Cassandra instance and maven (for building Java packages).

Setting Up the Cassandra Datastore

Before we can start the Docussandra API server that talks to Cassandra we have to create the keyspace where data will be stored. We do this by loading the schema found in the rest/src/main/resources/docussandra.cql directory. On the command line this looks like:

cqlsh -f rest/src/main/resources/docussandra.cql

Starting the Docussandra API

Next we need to build and run the API server. First, if using a command line, navigate to the api project folder in the root project. Once there, type:

mvn exec:java -Dexec.mainClass="com.strategicgains.docussandra.Main"

If successful, the Docussandra will now be listening to requests on 127.0.0.1:8081.

Creating a Database

Once the server has been started we can begin to interact with it. The first step is a create a database in which to store data. This can be done by making a POST request to:

http://localhost:8081/*{databaseName}*

The {databaseName} variable mentioned above can be whatever the user would like as long as it has not been previously used. Names must be globally unique and in lower case. Otherwise an error will result.

Creating a Table

To create a logical grouping of similar data we'll create a table. We can do this by making another POST request to:

http://localhost:8081/*{databaseName}*/*{tablename}*

Naming restrictions on the table name are similar to the database: unique to the database and in lower case.

Storing and Retrieving Data

Storing information to Docussandra is simple. To add a JSON document to a table that you've created, POST the document to the table.

Suppose that we're interested in storing information about the appearances of various superhero characters in comics. First, we need to create the database with Docussandra:

POST http://localhost:8081/comics

With our comic database created, we now need to create a table for JSON documents that describe our superhero (and villian) appearances.

POST http://localhost:8081/comics/appearances

What does that appearance JSON document look like? Perhaps we want to store something like:

{

	"name":"Wolverine",
	"date":"1974-11-01",
	"comic":"Incredible Hulk, The",
	"title":"And Now... the Wolverine!",
	"number":"181"

}

That JSON document contains a number of important pieces of information: the name of the character, the date of this appearance, the name of the comic, the title and number of the issue. Good stuff, to be sure. But in our use case we are most concerned with returning information primarily by the character name, followed by the date of the appearance. To do that, we need to create an index. We do this by posting to the reserved word indexes at our endpoint, followed by the name we're giving that index.

POST http://localhost:8081/comics/appearances/indexes/namedate

In the body of the POST, we include the fields within each JSON document that we want Docussandra to index the information by:

{ "fields":["name","date"] }

With the index created, we can now add our data.

POST http://localhost:8081/comics/appearances/

with a body of:

{ "name":"Wolverine", "date":"1974-11-01", "comic":"Incredible Hulk, The", "title":"And Now... the Wolverine!", "number":"181" }

Note: While and endpoint of "http://localhost:8081/comics/appearances" was used to create the table, data is written to be written to "http://localhost:8081/comics/appearances**/**", with a trailing slash.

We can retrieve all our appearances by making a GET request to our table:

GET http://localhost:8081/comics/appearances/

docussandra's People

Contributors

jeffreydeyoung avatar tfredrich avatar waffle-iron avatar

Watchers

Zo-Hasina Rasatavohary avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.