Giter Site home page Giter Site logo

ludwigachhammer / pivio-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pivio/pivio-server

0.0 0.0 0.0 287 KB

Central DB Server with a simple REST API. Backend by Elasticsearch.

License: Apache License 2.0

Dockerfile 0.22% Java 99.78%

pivio-server's Introduction

pivio-server

Aggregates all document information relevant for your platform.

Build Status

Build Status

How to run the server (without using Docker)

  1. Build pivio-server: ./gradlew build -x test (Note: If you want to run the tests, you need Docker)
  2. Install Elasticsearch 2.4.6
  3. Install the Elasticsearch Delete By Query Plugin
  4. Start Elasticsearch: elasticsearch
  5. Start pivio-server: java -jar build/libs/pivio-server-1.1.0.jar
  6. Access it at http://localhost:9123/{document|changeset} (see below)

How to run the server using Docker (Compose)

  1. Make sure Docker is running and you have Docker Compose installed
  2. Build pivio-server: ./gradlew build
  3. Start it, using docker-compose up - this will run Elasticsearch and pivio-server as Docker containers
  4. Access it at http://localhost:9123/{document|changeset} (see below)

If you need to rebuild the Docker images (e.g. when you patched the sources) run:

./gradlew [clean] build
docker-compose up [-d] --build

Insert document information

curl -H 'Content-Type: application/json' -X POST http://localhost:9123/document -d '{
  "id": "JustSomeId",
  "name": "Awesome Microservice",
  "type": "service",
  "owner": "lambda",
  "description": "Simple microservice"
}'

Retrieve document information

curl -H 'Content-Type: application/json' -X GET http://localhost:9123/document/JustSomeId

Retrieve changesets of documents

Everytime document is changed a new changeset will be generated.

Retrieve all changesets

curl -H 'Content-Type: application/json' -X GET http://localhost:9123/changeset

Retrieve all changesets for last 7 days

curl -H 'Content-Type: application/json' -X GET http://localhost:9123/changeset?since=7d

Retrieve all changesets for last 4 weeks

curl -H 'Content-Type: application/json' -X GET http://localhost:9123/changeset?since=4w

Retrieve all changesets of specific document

curl -H 'Content-Type: application/json' -X GET http://localhost:9123/document/JustSomeId/changeset

Retrieve all changesets of specific document for last 7 days

curl -H 'Content-Type: application/json' -X GET http://localhost:9123/document/JustSomeId/changeset?since=7d

Search API for document information

For searching, a query URL parameter can be passed (see examples below). Its value is a JSON string that needs to be URL encoded. That is, at least the following JSON characters need to be replaced:

  • { needs to be replaced by %7B
  • " needs to be replaced by %22
  • : needs to be replaced by %3A
  • } needs to be replaced by %7D
  • for a quick overview of further characters see Wikipedia's page Percent-encoding page

Search for each document of owner Lambda

curl -H 'Content-Type: application/json' -X GET 'http://localhost:9123/document?query={"match":{"owner":"lambda"}}&fields=talks_to'

Encoded:

curl -H 'Content-Type: application/json' -X GET 'http://localhost:9123/document?query=%7B%22match%22%3A%7B%22owner%22%3A%22lambda%22%7D%7D'

Search for each document of owner Lambda which has field talks_to present (will only return the field talks_to in results)

curl -H 'Content-Type: application/json' -X GET 'http://localhost:9123/document?query={"match":{"owner":"lambda"}}&fields=talks_to'

Encoded:

curl -H 'Content-Type: application/json' -X GET 'http://localhost:9123/document?query=%7B%22match%22%3A%7B%22owner%22%3A%22lambda%22%7D%7D&fields=talks_to'

Search for each document of owner Lambda and sort ascending by field lastUpdated

curl -H 'Content-Type: application/json' -X GET 'http://localhost:9123/document?query={"match":{"owner":"lambda"}}&sort=lastUpdate:asc'

Encoded:

curl -H 'Content-Type: application/json' -X GET 'http://localhost:9123/document?query=%7B%22match%22%3A%7B%22owner%22%3A%22lambda%22%7D%7D&sort=lastUpdate:asc'

You can sort descending with desc instead of asc. You can also sort by multiple fields, just truncate them via comma. Order is important in this case, e.g. lastUpdate:asc,owner:desc would first sort ascending by field lastUpdate and afterwards descending by field owner if two entries have same lastUpdate value.

You can use the whole query types of Elasticsearch Search API (Search API Documentation).

pivio-server's People

Contributors

bhelfert avatar ludwigachhammer avatar oliverwehrens 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.