De. Queries
Intelligent Service Discovery & Matching
Query De. logistics network in real-time. Find warehouses, carriers, terminals, and resources with intelligent matching, proximity scoring, and automatic fallback strategies.
What are De. Queries?
De. Queries provide intelligent, real-time discovery and matching of logistics resources across De. network. Think of it as Google Search for your supply chain - but instead of web pages, you're finding warehouses, carriers, terminals, and inventory with millisecond response times.
Key Capabilities:
- Service Discovery - Find warehouses, carriers, hubs, and terminals by location, capabilities, or custom criteria
- Intelligent Matching - AI-powered matching of orders to optimal service providers with multi-factor scoring
- Capacity Querying - Real-time capacity checks with caching for high-volume operations
- Performance Tracking - Monitor and query service provider performance metrics
- Pricing Queries - Estimate costs and compare pricing across providers
Perfect for: Order routing, warehouse selection, carrier assignment, capacity planning, performance analytics
Why De. Queries?
The Problem
Traditional logistics systems require hardcoded logic for service provider selection:
// ❌ Traditional approach: Brittle, hardcoded logic
async function selectWarehouse(orderId: string) {
// Manually fetch all warehouses
const warehouses = await db.collection('warehouses').find({ status: 'active' })
// Hardcoded distance calculation
let closest = null
let minDistance = Infinity
for (const warehouse of warehouses) {
const distance = calculateDistance(warehouse.location, order.destination)
if (distance < minDistance && warehouse.capacity > order.items.length) {
minDistance = distance
closest = warehouse
}
}
// No fallback if nothing matches
if (!closest) throw new Error('No warehouse found')
return closest
}Problems with this approach:
- 🔴 Hardcoded logic that's difficult to maintain
- 🔴 No intelligent scoring or optimization
- 🔴 Manual capacity checking
- 🔴 No performance tracking
- 🔴 Difficult to add new selection criteria
- 🔴 No fallback strategies
The Solution
De. Queries provide declarative, intelligent service discovery:
// ✅ The De. Queries way: Intelligent, declarative queries
const result = await client.realm.queries.discovery.discover({
serviceType: 'WAREHOUSE',
location: {
coordinates: order.destination,
maxDistance: 50 // km
},
capabilities: ['COLD_CHAIN', 'VALUE_ADDED_SERVICES'],
filters: {
minCapacity: order.items.length,
operatingHours: '24/7'
}
})
// Automatic scoring, capacity checking, and fallback
const warehouse = result.services[0]Benefits:
- ✅ Declarative queries with intelligent scoring
- ✅ Automatic capacity verification
- ✅ Built-in caching for performance
- ✅ Performance tracking and analytics
- ✅ Pricing estimation
- ✅ Easy to extend and maintain
Core Query Types
Discovery Queries
Find services by location, capabilities, and custom filters with intelligent proximity scoring
Learn more →Matching Queries
AI-powered matching of orders to optimal service providers with multi-factor scoring
Learn more →Capacity Queries
Real-time capacity checks with intelligent caching for high-volume operations
Learn more →Performance Queries
Track and query service provider performance metrics for data-driven decisions
Learn more →Pricing Queries
Estimate costs and compare pricing across providers for budget optimization
Learn more →Pipeline Integration
Use queries in automated pipelines for autonomous workflow execution
Learn more →Discovery Queries
Purpose: Find logistics services that match specific criteria
Basic Service Discovery
Find warehouses near a delivery location
import { DeClient } from '@dedot/sdk'
const client = new DeClient({ apiKey: 'your-key', workspace: 'your-workspace' })
// Find warehouses within 50km of delivery location
const result = await client.realm.queries.discovery.discover({
serviceType: 'WAREHOUSE',
location: {
coordinates: [40.7128, -74.0060], // [lat, lng]
maxDistance: 50
}
})
console.log(`Found ${result.total} warehouses`)
result.services.forEach(warehouse => {
console.log(`${warehouse.name}: ${warehouse.distance}km away`)
})Key Features:
- Geographic proximity filtering
- Capability-based filtering
- Custom attribute filters
- Sorted by relevance score
Advanced Discovery
Multi-criteria search with capability matching
// Find cold chain warehouses with specific capabilities
const result = await client.realm.queries.discovery.advancedDiscover({
serviceType: 'WAREHOUSE',
location: {
coordinates: [40.7128, -74.0060],
maxDistance: 100
},
capabilities: {
environmental: {
temperatureControlled: true,
temperatureRange: { min: -20, max: 5 }
},
handling: {
specialHandling: ['FRAGILE', 'HAZMAT']
}
},
filters: {
'compliance.certifications': { $in: ['HACCP', 'FDA'] },
'serviceLevel.orderProcessing.enabled': true
}
})Advanced Features:
- Deep capability matching
- Compliance filtering
- Service level requirements
- Performance thresholds
Matching Queries
Purpose: Intelligently match orders to optimal service providers
Order-to-Warehouse Matching
Find the best warehouse for an order
// Match order to optimal warehouse
const match = await client.realm.queries.matching.match({
serviceTypes: ['WAREHOUSE'],
delivery: {
country: 'US',
city: 'New York',
coordinates: [40.7128, -74.0060]
},
items: [
{ sku: 'PROD-001', quantity: 10, requiresColdChain: true },
{ sku: 'PROD-002', quantity: 5, weight: 2.5 }
],
requirements: ['SAME_DAY_DELIVERY', 'COLD_CHAIN'],
strategy: 'BALANCED'
})
console.log('Best match:', match.recommendations[0])
console.log('Scores:', match.recommendations[0].scores)
// {
// capability: 95,
// proximity: 88,
// capacity: 100,
// performance: 92,
// cost: 85,
// overall: 92
// }Matching Strategies:
BALANCED- Optimize across all factorsCOST_OPTIMIZED- Prioritize lowest costSPEED_OPTIMIZED- Prioritize fastest deliveryQUALITY_OPTIMIZED- Prioritize best performance
Multi-Service Matching
Match across warehouses, carriers, and terminals
// Match order across multiple service types
const match = await client.realm.queries.matching.match({
serviceTypes: ['WAREHOUSE', 'CARRIER', 'TERMINAL'],
delivery: {
country: 'US',
city: 'Los Angeles',
coordinates: [34.0522, -118.2437]
},
items: [/* order items */],
strategy: 'SPEED_OPTIMIZED'
})
// Get best matches for each service type
const warehouse = match.recommendations.find(r => r.serviceType === 'WAREHOUSE')
const carrier = match.recommendations.find(r => r.serviceType === 'CARRIER')
const terminal = match.recommendations.find(r => r.serviceType === 'TERMINAL')Capacity Queries
Purpose: Check real-time capacity availability with intelligent caching
Single Service Capacity
Query capacity for a specific warehouse
// Query warehouse capacity
const capacity = await client.realm.queries.capacity.query({
lsp: 'lsp-001',
serviceId: 'warehouse-123',
capacityType: 'STORAGE_SLOTS'
})
console.log('Available slots:', capacity.available)
console.log('Total slots:', capacity.total)
console.log('Utilization:', `${capacity.utilizationRate}%`)Capacity Types:
STORAGE_SLOTS- Warehouse storage positionsPALLET_POSITIONS- Pallet capacityVEHICLE_CAPACITY- Fleet availabilityDOCK_DOORS- Loading dock availability- Custom capacity types
Batch Capacity Queries
Query multiple services efficiently
// Batch query capacities for multiple warehouses
const result = await client.realm.queries.capacity.batchQuery({
queries: [
{ lsp: 'lsp-001', serviceId: 'warehouse-123', capacityType: 'STORAGE_SLOTS' },
{ lsp: 'lsp-001', serviceId: 'warehouse-456', capacityType: 'STORAGE_SLOTS' },
{ lsp: 'lsp-002', serviceId: 'warehouse-789', capacityType: 'PALLET_POSITIONS' }
]
})
// Results are cached for 5 minutes by default
result.capacities.forEach((capacity, serviceId) => {
console.log(`${serviceId}: ${capacity.available} available`)
})Caching Features:
- Automatic 5-minute cache by default
- Configurable cache duration
- Manual cache invalidation
- Cache statistics and monitoring
Performance Queries
Purpose: Track and analyze service provider performance
Performance Metrics
Query current performance data
// Get warehouse performance metrics
const performance = await client.realm.queries.performance.get({
lsp: 'lsp-001',
serviceId: 'warehouse-123'
})
console.log('Performance Summary:', {
onTimeDeliveryRate: performance.onTimeDeliveryRate,
orderAccuracy: performance.orderAccuracy,
averageProcessingTime: performance.averageProcessingTime,
damageRate: performance.damageRate,
overallScore: performance.overallScore
})Performance-Based Selection
Filter services by performance thresholds
// Find high-performing warehouses
const result = await client.realm.queries.discovery.discover({
serviceType: 'WAREHOUSE',
location: { coordinates: [40.7128, -74.0060], maxDistance: 50 },
performanceThresholds: {
onTimeDeliveryRate: 0.95, // 95%+
orderAccuracy: 0.98, // 98%+
overallScore: 85 // 85+
}
})Pricing Queries
Purpose: Estimate costs and compare pricing across providers
Cost Estimation
Get pricing estimate for a service
// Estimate fulfillment cost
const estimate = await client.realm.queries.pricing.estimate({
lsp: 'lsp-001',
serviceId: 'warehouse-123',
serviceType: 'WAREHOUSE',
orderContext: {
items: [
{ sku: 'PROD-001', quantity: 10 },
{ sku: 'PROD-002', quantity: 5 }
],
requirements: ['SAME_DAY_DELIVERY'],
deliveryLocation: {
country: 'US',
city: 'New York'
}
}
})
console.log('Cost Estimate:', {
total: estimate.totalCost,
currency: estimate.currency,
breakdown: {
baseRate: estimate.breakdown.baseRate,
surcharges: estimate.breakdown.surcharges,
taxes: estimate.breakdown.taxes,
fees: estimate.breakdown.fees
}
})Price Comparison
Compare pricing across multiple providers
// Compare pricing across warehouses
const comparison = await client.realm.queries.pricing.compare({
services: [
{ lsp: 'lsp-001', serviceId: 'warehouse-123', serviceType: 'WAREHOUSE' },
{ lsp: 'lsp-002', serviceId: 'warehouse-456', serviceType: 'WAREHOUSE' },
{ lsp: 'lsp-003', serviceId: 'warehouse-789', serviceType: 'WAREHOUSE' }
],
orderContext: {
items: [/* order items */],
requirements: ['SAME_DAY_DELIVERY']
}
})
// Get cheapest option
console.log('Cheapest:', comparison.cheapest)
// Compare all options
comparison.comparisons.forEach(comp => {
console.log(`${comp.serviceId}: $${comp.totalCost}`)
})Pipeline Integration
De. Queries power De. Pipelines for autonomous workflow execution:
{
"stage": "Select Warehouse",
"action": "QUERY",
"query": {
"resource": "WAREHOUSE",
"filters": {
"capabilities": ["COLD_CHAIN"],
"region": "${execution.metadata.region}"
},
"strategy": "CLOSEST"
},
"transitions": {
"onSuccess": { "next": "Assign Carrier" }
}
}Key Features
Lightning Fast
Sub-100ms query response times with intelligent caching and optimized indexes
Service-Type Agnostic
Query warehouses, carriers, terminals, IoT devices, and custom service types
Multi-Factor Scoring
Intelligent scoring based on proximity, capacity, performance, cost, and capabilities
Automatic Caching
Intelligent cache management for capacity and pricing queries
Fallback Strategies
Automatic fallback to alternative services when primary matches fail
Performance Tracking
Real-time performance metrics for data-driven service selection
When to Use De. Queries
✅ Ideal Use Cases
Order Routing & Fulfillment
- Select optimal warehouse for order fulfillment
- Assign carriers based on cost, speed, and performance
- Route orders through multi-stage pipelines
Capacity Planning
- Real-time capacity checks before order acceptance
- Batch capacity queries for inventory planning
- Utilization monitoring and alerts
Performance Analytics
- Track service provider performance over time
- Compare providers for contract negotiations
- Identify underperforming services
Cost Optimization
- Compare pricing across multiple providers
- Estimate fulfillment costs before commitment
- Optimize for cost vs. speed trade-offs
Dynamic Resource Selection
- Find nearest available warehouse
- Select carrier with best on-time performance
- Route through terminals with available capacity
❌ When NOT to Use
Static Configurations
- Hardcoded warehouse assignments that never change
- Single-provider scenarios with no alternatives
Sub-Millisecond Requirements
- Queries optimized for 50-100ms response times
- Not suitable for microsecond-level real-time systems
Simple Lookups
- Direct database queries by ID
- No scoring or matching logic needed
Getting Started
Ready to start querying De. logistics network?

