Query DSL
Overview
Infino supports Query DSL, a JSON-based query language fully compatible with OpenSearch/Elasticsearch syntax. This enables seamless migration and use of your existing client libraries, tools, and applications while providing powerful search, aggregation, and analytics capabilities.
Endpoint
GET /{dataset}/querydsl
Execute a Query DSL search against the specified dataset.
Basic Query Structure
All Query DSL requests follow this basic structure:
{
"query": {
// Query definition
},
"aggs": {
// Aggregations (optional)
},
"sort": [
// Sort criteria (optional)
],
"size": 10, // Number of results to return
"from": 0, // Offset for pagination
"_source": ["field1", "field2"] // Fields to include
}
Quick Start Example
Search for errors in the last hour:
Request:
{
"query": {
"bool": {
"must": [
{"match": {"level": "error"}}
],
"filter": [
{"range": {"@timestamp": {"gte": "now-1h"}}}
]
}
},
"sort": [{"@timestamp": "desc"}],
"size": 2
}
Response:
{
"took": 15,
"timed_out": false,
"hits": {
"total": {
"value": 1247,
"relation": "eq"
},
"max_score": null,
"hits": [
{
"_index": "logs-2024",
"_id": "abc123",
"_score": null,
"_source": {
"@timestamp": "2024-01-15T14:30:00Z",
"level": "error",
"message": "Database connection failed",
"service": "api-gateway",
"host": "web-01"
},
"sort": [1705328600000]
},
{
"_index": "logs-2024",
"_id": "def456",
"_score": null,
"_source": {
"@timestamp": "2024-01-15T14:25:00Z",
"level": "error",
"message": "Authentication timeout",
"service": "auth-service",
"host": "web-02"
},
"sort": [1705328300000]
}
]
}
}
Query Types
Term-Level Queries
- term, terms, range, exists, prefix, wildcard
Full-Text Queries
- match, match_phrase, query_string, match_all
Compound Queries
- bool query with must, should, filter clauses
Geo and Vector Queries
- geo_distance, geo_bounding_box, knn
Aggregations
- Metric: avg, sum, min, max, cardinality
- Bucket: terms, date_histogram, range, filters
Advanced Features
- Multi-search, pagination, source filtering
Common Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
size | integer | 10 | Number of results to return (max: 10000) |
from | integer | 0 | Pagination offset for result set |
timeout | string | - | Request timeout (e.g., "30s", "1m") |
track_total_hits | boolean | true | Whether to track total hit count accurately |
_source | array/object/boolean | true | Controls which fields are returned in results |