In February 2021 Logmore launched a new Search API to provide better search capabilities. Search API allows users to search Loggers and Mission by using AND-type queries. Search API also has support for text-based search queries.
Search API
Endpoints
Here are listed all Logmore Search API endpoints. All endpoints require a valid JWT-token.
Request
- limit → limit search result set to given amount of objects. 1000 is max value for limit.
- skip → skip given amount of objects from the start.
- filter → array containing AND-type conditionals
- field → object field
- method → search query method
- value → search query value.
- sort
- field → is the object field used for sorting
- order → sort order. 1 is for ascending and -1 is for descending.
- include_count → If true total count of all objects matching to query is included.
Request body format
{
"limit" : 20,
"filters" : [
{"field" : "last_scan_location","method" : "contains", "value" : "Jyväskylä"},
{"field" : "last_scan.created_at","method" : ">=", "value" : "2021-02-01T00:00:00Z"},
{"field" : "has_ongoing_missions","method" : "=", "value" : true}
],
"sort" : {
"field" : "last_scan.created_at",
"order" : -1
},
"include_count" : true
}
Supported search methods
-
Equal "="
{"field" : "has_ongoing_missions","method" : "=", "value" : true}
-
Not Equal "!="
{"field" : "has_ongoing_missions","method" : "!=", "value" : true}
-
Greater Than ">"
{"field" : "last_scan.created_at","method" : ">", "value" : "2021-02-01T00:00:00Z"},
-
Greater Than or Equal ">="
{"field" : "last_scan.created_at","method" : ">=", "value" : "2021-02-01T00:00:00Z"},
-
Lesser Than "<"
{"field" : "last_scan.created_at","method" : "<", "value" : "2021-02-01T00:00:00Z"},
-
Lesser Than or Equal "<="
{"field" : "last_scan.created_at","method" : "<=", "value" : "2021-02-01T00:00:00Z"},
-
Is one of (IN type query) "is_one_of"
{"field" : "serial","method" : "is_one_of", "value" : [1337,50]},
-
Is not one of of (NOT IN type query) "is_not_one_of"
{"field" : "serial","method" : "is_not_one_of", "value" : [1337,50]},
-
Contains text "contains". NOTE: not supported in all fields. Currently, supported fields are
- Loggers
- name
- serial
- last_scan_location
- Missions
- name
- last_scan_location
User can provide multiple search words by separating search terms by whitespace " ". In following example, search query will return all objects where last_scan_location contains either "Jyväskylä" or "Helsinki".
{"field" : "last_scan_location","method" : "contains", "value" : "Jyväskylä Helsinki"},
- Loggers
Response
- total_count → Total count of items that matched search query
- has_more_items → tells if there exists more items excluded by limit.
- result → array contains objects that matched search criteria
Example Response
{
"total_count": 1,
"has_more_items": true,
"result": [
{
"id": "1d8a2552e2d33b002d15e444",
"allowed_operations": [
"can_edit",
"can_read",
"can_leave_comments",
"can_end_mission"
],
"name": "Mission",
"permissions": [
{
"subject_id": "1d8a2552e2d33b002d15e444",
"subject_type": "team",
"acc_lvl": "mission_write",
"user_email": "support@logmore.com (if subject_type 'user' type)",
"user_name": "Username",
"team_name": "Logmore LTD (if subject_type 'team' type)",
"created_at": "2020-07-27T08:00:46.64Z"
}
],
"updated_at": "2019-09-25T06:09:56.39Z",
"created_at": "2019-09-25T06:09:56.39Z",
"starts_at": "2019-09-25T06:09:56.39Z",
"ends_at": "2019-09-26T06:09:56.39Z",
"log": [
{
"ts": "2020-07-27T08:00:46.64Z",
"edited_by": "5c03c368056bd6002febf37b",
"data": {}
}
],
"loggers": [
"5c03c368056bd6002febf37b"
],
"alert_rules_ids": [
"5c03c368056bd6002febfccc"
],
"note": "Mission note",
"ended_by": "5c03c368056bd6002febf37c",
"public": true,
"archived": true,
"has_alerts": true,
"has_unacked_alerts": true,
"needs_attention": true,
"last_scan": {
"id": "5d67f8501e35d2003070419b",
"logger_id": "5c03c368056bd6002febf37b",
"new_data": 371,
"data_count": 371,
"device_conf_version": 0,
"config_id": "5bcf245513f7c9002048a1d1",
"location": {
"type": "point",
"coordinates": [
0
]
},
"protocol": 0,
"battery_level": "40",
"created_at": "2019-08-29T16:07:44.415Z",
"ip": "90.125.104.111",
"useragent": "Mozilla/5.0 (iPhone; CPU iPhone OS 12_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Mobile/15E148 Safari/604.1",
"status": "ok"
},
"mission_loggers": [
{
"id": "5c03c368056bd6002febf37b",
"name": "Demo Tag",
"note": "Note",
"meta": {},
"public_meta": {},
"serial": 1337,
"model": "Model 3",
"public": true
}
],
"mission_template_id": "5c03c368056bd6002febfaaa",
"status": "Ongoing | Scheduled | Ended"
}
]
}
Loggers SearchAPI
Example how to search Loggers
curl --location --request POST '<https://api-c2.logmore.com/search/loggers>' \\
--header 'Authorization: Bearer <jwt_token>' \\
--header 'Content-Type: application/json' \\
--data-raw '{
"limit" : 20,
"filters" : [
{"field" : "model" ,"method" : "=", "value" : "Model 2"},
{"field" : "last_scan.created_at" ,"method" : ">=", "value" : "2021-02-01T00:00:00Z"},
{"field" : "last_scan_location" ,"method" : "contains", "value" : "Helsinki"}
],
"sort" : {
"field" : "last_scan.created_at",
"order" : -1
},
"include_count" : false
}'
Get List of searchable logger fields
Example Request
curl --location --request GET '<https://api-c2.logmore.com/search/loggers/help>' \\
--header 'Authorization: Bearer <jwt_token>'
Example Response
[
{
"field": "serial",
"type": "int64"
},
{
"field": "has_ongoing_missions",
"type": "bool"
},
{
"field": "has_ended_missions",
"type": "bool"
},
{
"field": "has_scheduled_missions",
"type": "bool"
},
{
"field": "updated_at",
"type": "string"
},
{
"field": "model",
"type": "string"
},
{
"field": "archived",
"type": "bool"
},
{
"field": "last_scan_location",
"type": "string"
},
{
"field": "permissions.subject_id",
"type": "string"
},
{
"field": "permissions.subject_type",
"type": "string"
},
{
"field": "permissions.acc_lvl",
"type": "string"
},
{
"field": "last_scan.created_at",
"type": "string"
},
{
"field": "id",
"type": "string"
},
{
"field": "name",
"type": "string"
},
{
"field": "latest_measurement_time",
"type": "string"
},
{
"field": "created_at",
"type": "string"
}
]
Missions SearchAPI
Example how to search Missions
curl --location --request POST '<https://api-c2.logmore.com/search/missions>' \\
--header 'Authorization: Bearer <jwt_token>' \\
--header 'Content-Type: application/json' \\
--data-raw '{
"limit" : 20,
"filters" : [
{"field" : "last_scan.created_at" ,"method" : ">=", "value" : "2021-02-01T00:00:00Z"},
{"field" : "last_scan_location" ,"method" : "contains", "value" : "Helsinki"}
],
"sort" : {
"field" : "last_scan.created_at",
"order" : -1
},
"include_count" : true
}'
Get List of searchable logger fields
Example Request
curl --location --request GET '<https://api-c2.logmore.com/search/missions/help>' \\
--header 'Authorization: Bearer <jwt_token>'
Example Response
[
{
"field": "alert_rules_ids",
"type": "string"
},
{
"field": "status",
"type": "string"
},
{
"field": "has_unacked_alerts",
"type": "bool"
},
{
"field": "permissions.acc_lvl",
"type": "string"
},
{
"field": "permissions.subject_id",
"type": "string"
},
{
"field": "permissions.subject_type",
"type": "string"
},
{
"field": "loggers",
"type": "string"
},
{
"field": "starts_at",
"type": "string"
},
{
"field": "archived",
"type": "bool"
},
{
"field": "mission_template_id",
"type": "string"
},
{
"field": "needs_attention",
"type": "bool"
},
{
"field": "name",
"type": "string"
},
{
"field": "ends_at",
"type": "string"
},
{
"field": "last_scan.created_at",
"type": "string"
},
{
"field": "last_scan_location",
"type": "string"
},
{
"field": "has_alerts",
"type": "bool"
},
{
"field": "updated_at",
"type": "string"
},
{
"field": "created_at",
"type": "string"
},
{
"field": "id",
"type": "string"
}
]