/v2/analysis/validate
Validates the structure, references and parameter values of an analysis request without computing anything.
Access Methods
POST
URL Parameters
None
Request Body
The request body must contain exactly one JSON object with a complete analysis request to be validated.
The request should specify an appropriate Content-​Type
header equal to
application/json
.
Response
Validation result is a subset of the full analysis result, limited to the
status
and log
blocks of the result JSON. If the input analysis passes validation
checks, V​A​L​I​D
status is returned. Otherwise, an error identical to that returned from the
analysis result endpoint is returned.
Note that the validation endpoint returns HTTP code 200 (OK) even for those requests that are not valid (don't pass validation checks). This is different to any other analysis-related endpoints, which would indicate an error using HTTP status code and the error JSON in the response.
Errors
The validation endpoint does not return error status codes, it always returns HTTP 200 (OK).
Examples
Let's post an invalid JSON file like this one:
{
Ooops, this is not valid json.
}
to the validation endpoint using the following curl
command:
curl -XPOST -H "Content-Type: application/json" --data @analysis-validation-invalid.request.json http://localhost:8080/api/v2/analysis/validate
this translates to the following full HTTP request:
POST /api/v2/analysis/validate HTTP/1.1
Content-Type: application/json
{
Ooops, this is not valid json.
}
to which the server returns the following response, indicating an error in the input request:
HTTP/1.1 200 OK
content-length: 491
content-type: application/json;charset=utf-8
{
"status" : {
"status" : "FAILED",
"error" : "Invalid analysis request configuration"
},
"log" : [
{
"level" : "ERROR",
"code" : "E001",
"message" : "JSON parse error.",
"details" : {
"description" : "Unexpected character (',' (code 44)): was expecting a colon to separate field name and value",
"json" : "{\n Ooops, this is not valid json.\n}\n",
"line" : 2,
"column" : 9,
"offset" : 10
}
}
]
}
For a valid analysis JSON like this one:
{
"stages": {
"documents": {
"type": "documentContent",
"documents": {
"type": "documents:byQuery",
"query": {
"type": "query:string",
"query": "photon"
},
"limit": 3
},
"fields":{
"type": "contentFields:simple",
"fields": {
"title": {}
}
}
}
}
}
the validation endpoint returns the following response:
HTTP/1.1 200 OK
content-length: 60
content-type: application/json;charset=utf-8
{
"status" : {
"status" : "VALID"
},
"log" : [ ]
}