Overview

This document contains description of REST endpoints and format of requests/responses for using Query Service.

1. Happy Path

1.1. Example Request

POST /query-service/search/all HTTP/1.1
Content-Type: application/json
Accept: application/json
Content-Length: 451
Host: localhost:8080

{
  "type": "apple",
  "limit": 10,
  "offset": 4,
  "xmlns$corpus": "http://www.censhare.com/xml/3.0.0/corpus",
  "term": {
    "name": "censhare:text.meta",
    "value": "apple"
  },
  "sortorders": {
    "order": {
      "ascending": true,
      "by": "censhare:asset.name"
    }
  },
  "and": {
    "or": {
      "condition": {
        "altresults": true,
        "altresult-labels": true,
        "name": "censhare:asset.type"
      }
    }
  }
}

1.2. Example Request Payload

Path Type Description
type

String

Asset type

limit

Number

Number of results to retrieve

offset

Number

Number of first results to skip

xmlns$corpus

String

XML schema

term

Object

Term info

term.name

String

Term name

term.value

String

Term value

sortorders

Object

Sorting info

sortorders.order.ascending

Boolean

Sorting direction

sortorders.order.by

String

Sorting field

and

Object

Additional conditions

1.3. Example Response

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 639

{"assetIds":[10007,10004,10005,10006],"pagination":{"totalCount":144,"limit":10,"offset":0},"alternativeResults":[{"index_key":"censhare:text.name","index_label":"Name (full text)","corpus$key":"","count":1,"altresult":{"corpus$label":"Apple","corpus$value":"apple","corpus$count":8}},{"corpus$key":"and.or.condition","corpus$feature":"censhare:asset.type","corpus$table":"asset_typedef","corpus$value_type":"HIERARCHICAL","corpus$value-col":"asset_type","count":2,"altresult":[{"corpus$count":8,"corpus$is_empty":"true"},{"asset_type":"picture.","corpus$label":"Image","corpus$value":"picture.","corpus$count":8}],"corpus$label":"Type"}]}

1.4. Example Response Payload

Path Type Description
assetIds

Array

IDs of the assets

pagination

Object

Pagination info

pagination.totalCount

Number

Total number of results available for the provided request

pagination.limit

Number

Limit for the results to retrieve

pagination.offset

Number

Number of first results that have been skipped

alternativeResults

Array

Alternative results

2. Error, when Legacy Server is down

2.1. Example Request

POST /query-service/search/all HTTP/1.1
Content-Type: application/json
Accept: application/json
Content-Length: 451
Host: localhost:8080

{
  "type": "apple",
  "limit": 10,
  "offset": 4,
  "xmlns$corpus": "http://www.censhare.com/xml/3.0.0/corpus",
  "term": {
    "name": "censhare:text.meta",
    "value": "apple"
  },
  "sortorders": {
    "order": {
      "ascending": true,
      "by": "censhare:asset.name"
    }
  },
  "and": {
    "or": {
      "condition": {
        "altresults": true,
        "altresult-labels": true,
        "name": "censhare:asset.type"
      }
    }
  }
}

2.2. Example Request Payload

Path Type Description
type

String

Asset type

limit

Number

Number of results to retrieve

offset

Number

Number of first results to skip

xmlns$corpus

String

XML schema

term

Object

Term info

term.name

String

Term name

term.value

String

Term value

sortorders

Object

Sorting info

sortorders.order.ascending

Boolean

Sorting direction

sortorders.order.by

String

Sorting field

and

Object

Additional conditions

2.3. Example Response

HTTP/1.1 500 Internal Server Error
Content-Type: application/json
Content-Length: 252

{"refId":1,"message":"UNKNOWN","status":"INTERNAL_SERVER_ERROR","code":500,"timestamp":"15-03-2021 05:38:59","path":"/query-service/search/all","debugMessage":"block()/blockFirst()/blockLast() are blocking, which is not supported in thread parallel-2"}

2.4. Example Response Payload

Path Type Description
refId

Number

Identifier, used for tracing

message

String

Error message

status

String

HTTP status of the error

code

Number

HTTP status code of the error

timestamp

String

The timestamp defining when the error has occurred

path

String

The endpoint when the error has occurred

debugMessage

String

More detailed debug message describing the problem

3. Error, when empty Legacy Server response

3.1. Example Request

POST /query-service/search/all HTTP/1.1
Content-Type: application/json
Accept: application/json
Content-Length: 451
Host: localhost:8080

{
  "type": "apple",
  "limit": 10,
  "offset": 4,
  "xmlns$corpus": "http://www.censhare.com/xml/3.0.0/corpus",
  "term": {
    "name": "censhare:text.meta",
    "value": "apple"
  },
  "sortorders": {
    "order": {
      "ascending": true,
      "by": "censhare:asset.name"
    }
  },
  "and": {
    "or": {
      "condition": {
        "altresults": true,
        "altresult-labels": true,
        "name": "censhare:asset.type"
      }
    }
  }
}

3.2. Example Request Payload

Path Type Description
type

String

Asset type

limit

Number

Number of results to retrieve

offset

Number

Number of first results to skip

xmlns$corpus

String

XML schema

term

Object

Term info

term.name

String

Term name

term.value

String

Term value

sortorders

Object

Sorting info

sortorders.order.ascending

Boolean

Sorting direction

sortorders.order.by

String

Sorting field

and

Object

Additional conditions

3.3. Example Response

HTTP/1.1 500 Internal Server Error
Content-Type: application/json
Content-Length: 194

{"refId":1,"message":"UNKNOWN","status":"INTERNAL_SERVER_ERROR","code":500,"timestamp":"15-03-2021 05:39:00","path":"/query-service/search/all","debugMessage":"Null response from legacy server"}

3.4. Example Response Payload

Path Type Description
refId

Number

Identifier, used for tracing

message

String

Error message

status

String

HTTP status of the error

code

Number

HTTP status code of the error

timestamp

String

The timestamp defining when the error has occurred

path

String

The endpoint when the error has occurred

debugMessage

String

More detailed debug message describing the problem