Skip to content
This repository has been archived by the owner on Nov 5, 2020. It is now read-only.
/ search-service Public archive

Search/indexing frontend for out ElasticSearch

License

Notifications You must be signed in to change notification settings

telemark/search-service

Repository files navigation

Build Status js-standard-style

search-service

Search/indexing frontend for our ElasticSearch

API

GETs and POSTs are open.

PUTs and DELETEs requires a valid jwt

GET /

Returns this page

PUT /api/documents

Adds a new document to index.

You'll need do supply index, type, id and the document itself in the body property. See the example

http PUT http://localhost:3000/api/documents Authorization:'Bearer ' < test/data/document.json

returns

{
    "_id": "1",
    "_index": "test",
    "_primary_term": 1,
    "_seq_no": 0,
    "_shards": {
        "failed": 0,
        "successful": 1,
        "total": 2
    },
    "_type": "document",
    "_version": 1,
    "result": "created"
}

GET /api/search

Search indexed documents with a regular GET request

$ http GET http://localhost:3000/api/search?q=wunderbar

returns

{
    "_shards": {
        "failed": 0,
        "skipped": 0,
        "successful": 6,
        "total": 6
    },
    "hits": {
        "hits": [
            {
                "_id": "1",
                "_index": "test",
                "_score": 0.2876821,
                "_source": {
                    "description": "A short story about my feelings",
                    "title": "I feel wunderbar"
                },
                "_type": "document"
            }
        ],
        "max_score": 0.2876821,
        "total": 1
    },
    "timed_out": false,
    "took": 59
}

GET /api/:index/search

Search indexed documents with a regular GET request.

Filters by :index

$ http GET http://localhost:3000/api/test/search?q=wunderbar

returns

{
    "_shards": {
        "failed": 0,
        "skipped": 0,
        "successful": 6,
        "total": 6
    },
    "hits": {
        "hits": [
            {
                "_id": "1",
                "_index": "test",
                "_score": 0.2876821,
                "_source": {
                    "description": "A short story about my feelings",
                    "title": "I feel wunderbar"
                },
                "_type": "document"
            }
        ],
        "max_score": 0.2876821,
        "total": 1
    },
    "timed_out": false,
    "took": 59
}

POST /api/search

Search indexed documents by POSTing a json request

$ http POST http://localhost:3000/api/search q=wunderbar
{
    "_shards": {
        "failed": 0,
        "skipped": 0,
        "successful": 6,
        "total": 6
    },
    "hits": {
        "hits": [
            {
                "_id": "1",
                "_index": "test",
                "_score": 0.2876821,
                "_source": {
                    "description": "A short story about my feelings",
                    "title": "I feel wunderbar"
                },
                "_type": "document"
            }
        ],
        "max_score": 0.2876821,
        "total": 1
    },
    "timed_out": false,
    "took": 59
}

POST /api/:index/search

Search indexed documents by POSTing a json request.

Filters by :index

$ http POST http://localhost:3000/api/test/search q=wunderbar
{
    "_shards": {
        "failed": 0,
        "skipped": 0,
        "successful": 6,
        "total": 6
    },
    "hits": {
        "hits": [
            {
                "_id": "1",
                "_index": "test",
                "_score": 0.2876821,
                "_source": {
                    "description": "A short story about my feelings",
                    "title": "I feel wunderbar"
                },
                "_type": "document"
            }
        ],
        "max_score": 0.2876821,
        "total": 1
    },
    "timed_out": false,
    "took": 59
}

DELETE /api/indexes/:index

Deletes a given index

$ http DELETE http://localhost:3000/api/indexes/test Authorization:'Bearer <jwt-token>'

returns

{
    "acknowledged": true
}

GET /api/ping

Ping for pong

$ http GET http://localhost:3000/api/ping

returns

pong

Licence

MIT