Base URL:
https://api.opensearch.prod.trysolved.com/Index:
incidents_v1Auth:
Use Basic Auth with your OpenSearch username and password.
Use the HTTP Authorization header like this:
Authorization: Basic <base64(username:password)>You can generate the base64 string with the following command:
Linux/macOS (bash):
echo -n 'username:password' | base64 Windows (PowerShell):
[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("username:password")) To search the index:
POST https://api.opensearch.prod.trysolved.com/incidents_v1/_searchHeaders:
Content-Type: application/json
Authorization: Basic <base64 string>From your indexing function, here are the key fields:
|
| Field Type Notes |
| string | Incident ID |
| string | Incident category |
| string | ID of associated company |
| ISO date | Incident creation date |
| string | Description (analyzed) |
| string | Case-insensitive search field |
| string | Plant/location |
| string | Priority level |
| string | Incident status |
| string | Template ID used |
| string | External reference ID |
| string | Product type |
| object | User info fields like |
POST /incidents_v1/_search
{
"query": {
"match_all": {}
},
"size": 10
}POST /incidents_v1/_search
{
"query": {
"term": {
"status.keyword": "open"
}
}
}POST /incidents_v1/_search
{
"query": {
"bool": {
"must": [
{ "term": { "category.keyword": "safety" } },
{ "term": { "priority": 0 } }
]
}
}
}POST /incidents_v1/_search
{
"query": {
"match": {
"description": "chemical spill"
}
}
}POST /incidents_v1/_search
{
"query": {
"range": {
"creationDate": {
"gte": "2024-01-01T00:00:00Z",
"lte": "2024-12-31T23:59:59Z"
}
}
}
}POST /incidents_v1/_search
{
"query": {
"term": {
"creator.email.keyword": "[email protected]"
}
}
}POST /incidents_v1/_search
{
"size": 0,
"aggs": {
"by_status": {
"terms": {
"field": "status.keyword"
}
}
}
}curl -X POST "https://api.opensearch.prod.trysolved.com/incidents_v1/_search" \
-u 'your_username:your_password' \
-H "Content-Type: application/json" \
-d '{
"query": {
"term": { "status.keyword": "open" }
}
}'Use .keyword fields for exact string matching.
Use "size" and "from" for pagination.
Use "match" for fuzzy or full-text search.
Limit returned fields with _source, e.g.:
"_source": ["id", "status", "priority"]
Here is a postman collection containing the previous examples
In order to use it follow the following step.
Save the following json content into a file (eg: postman_incidents.json)
Import this file into Postman
Click on the collection name you just imported and in Authorization set your username and password
Pick the collection you want to try (eg Filter by Status) go into Body so you can see the query body and edit it if you want to.
Click Send
{
"info": {
"name": "OpenSearch API - incidents_v1",
"description": "OpenSearch API queries for the `incidents_v1` index using Basic Auth.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "1. Match All Incidents",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"query\": { \"match_all\": {} },\n \"size\": 10\n}"
},
"url": {
"raw": "{{baseURL}}/incidents_v1/_search",
"host": [
"{{baseURL}}"
],
"path": [
"incidents_v1",
"_search"
]
}
},
"response": []
},
{
"name": "2. Filter by Status",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"query\": {\n \"term\": { \"status.keyword\": \"open\" }\n }\n}"
},
"url": {
"raw": "{{baseURL}}/incidents_v1/_search",
"host": [
"{{baseURL}}"
],
"path": [
"incidents_v1",
"_search"
]
}
},
"response": []
},
{
"name": "3. Filter by Category and Priority",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"query\": {\n \"bool\": {\n \"must\": [\n { \"term\": { \"category.keyword\": \"safety\" } },\n { \"term\": { \"priority\": 0 } }\n ]\n }\n }\n}"
},
"url": {
"raw": "{{baseURL}}/incidents_v1/_search",
"host": [
"{{baseURL}}"
],
"path": [
"incidents_v1",
"_search"
]
}
},
"response": []
},
{
"name": "4. Full-text Search in Description",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"query\": {\n \"match\": {\n \"description\": \"chemical spill\"\n }\n }\n}"
},
"url": {
"raw": "{{baseURL}}/incidents_v1/_search",
"host": [
"{{baseURL}}"
],
"path": [
"incidents_v1",
"_search"
]
}
},
"response": []
},
{
"name": "5. Date Range by Creation Date",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"query\": {\n \"range\": {\n \"creationDate\": {\n \"gte\": \"2024-01-01T00:00:00Z\",\n \"lte\": \"2024-12-31T23:59:59Z\"\n }\n }\n }\n}"
},
"url": {
"raw": "{{baseURL}}/incidents_v1/_search",
"host": [
"{{baseURL}}"
],
"path": [
"incidents_v1",
"_search"
]
}
},
"response": []
},
{
"name": "6. Filter by Creator Email",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"query\": {\n \"term\": {\n \"creator.email.keyword\": \"[email protected]\"\n }\n }\n}"
},
"url": {
"raw": "{{baseURL}}/incidents_v1/_search",
"host": [
"{{baseURL}}"
],
"path": [
"incidents_v1",
"_search"
]
}
},
"response": []
},
{
"name": "7. Aggregation by Status",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"size\": 0,\n \"aggs\": {\n \"by_status\": {\n \"terms\": {\n \"field\": \"status.keyword\"\n }\n }\n }\n}"
},
"url": {
"raw": "{{baseURL}}/incidents_v1/_search",
"host": [
"{{baseURL}}"
],
"path": [
"incidents_v1",
"_search"
]
}
},
"response": []
}
],
"auth": {
"type": "basic",
"basic": [
{
"key": "password",
"value": "",
"type": "string"
},
{
"key": "username",
"value": "",
"type": "string"
}
]
},
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"packages": {},
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"packages": {},
"exec": [
""
]
}
}
],
"variable": [
{
"key": "baseURL",
"value": "https://api.opensearch.prod.trysolved.com",
"type": "default"
}
]
}
Check the official Opensearch API Reference for more details