Practice & Implementation - Module 7: Pagination & Result Shaping¶
Learning Path¶
This module provides hands-on exercises to master pagination and result shaping in Azure AI Search. Work through the exercises in order, building complexity as you progress.
Exercise 1: Basic Skip/Top Pagination¶
Objective¶
Implement basic pagination using skip and top parameters.
Tasks¶
-
Simple Pagination
-
Add Result Counting
-
Implement Page Navigation Logic
- Calculate total pages from result count
- Generate page numbers
- Handle edge cases (first/last page)
Expected Results¶
- Consistent page sizes across requests
- Proper total count calculation
- Working next/previous navigation
Code Implementation¶
See Code Samples for language-specific implementations.
Exercise 2: Field Selection and Result Shaping¶
Objective¶
Control which fields are returned to optimize response size and performance.
Tasks¶
-
Basic Field Selection
-
Different Views for Different Contexts
-
Performance Comparison
- Measure response times with/without field selection
- Compare payload sizes
- Document performance improvements
Expected Results¶
- Reduced response payload sizes
- Faster response times
- Appropriate field selection for different use cases
Exercise 3: Hit Highlighting¶
Objective¶
Implement hit highlighting to emphasize search terms in results.
Tasks¶
-
Basic Highlighting
-
Multiple Field Highlighting
-
Custom Highlighting Tags
-
Process Highlighting Results
- Extract highlighted snippets
- Display highlighted terms in UI
- Handle multiple highlights per field
Expected Results¶
- Search terms highlighted in results
- Custom highlighting tags applied
- Proper handling of multiple highlights
Exercise 4: Range-Based Pagination¶
Objective¶
Implement efficient pagination for large datasets using range filters.
Tasks¶
-
Setup Sortable Field
-
Implement Range-Based Navigation
-
Handle Edge Cases
- Empty result sets
- Last page detection
- Concurrent data changes
Expected Results¶
- Consistent performance regardless of page depth
- Proper handling of data changes during pagination
- Efficient navigation through large result sets
Exercise 5: Search After Pattern¶
Objective¶
Implement the search after pattern for optimal deep pagination performance.
Tasks¶
-
Compound Sorting Setup
-
Implement Search After
-
Client-Side Logic
- Extract sort values from results
- Build search after parameters
- Handle navigation state
Expected Results¶
- Optimal performance for deep pagination
- Consistent results during concurrent updates
- Proper search after value extraction
Exercise 6: Advanced Result Shaping¶
Objective¶
Combine multiple result shaping techniques for optimal user experience.
Tasks¶
-
Comprehensive Search Interface
-
Faceted Search with Pagination
-
Search Suggestions with Highlighting
Expected Results¶
- Rich search interface with multiple features
- Proper integration of pagination with faceting
- Enhanced user experience with highlighting
Exercise 7: Performance Optimization¶
Objective¶
Optimize pagination and result shaping for production scenarios.
Tasks¶
- Performance Benchmarking
- Measure response times for different page sizes
- Compare skip/top vs range-based pagination
-
Test with large result sets (10,000+ documents)
-
Caching Implementation
- Implement result caching
- Cache pagination metadata
-
Handle cache invalidation
-
Memory Management
- Set maximum page sizes
- Implement timeout handling
- Monitor resource usage
Expected Results¶
- Documented performance characteristics
- Effective caching strategy
- Production-ready pagination implementation
Exercise 8: Error Handling and Edge Cases¶
Objective¶
Build robust pagination with proper error handling.
Tasks¶
-
Parameter Validation
-
Error Recovery
- Handle rate limiting (429 errors)
- Retry with exponential backoff
-
Graceful degradation for service issues
-
Edge Case Handling
- Empty result sets
- Invalid pagination parameters
- Concurrent data modifications
Expected Results¶
- Robust error handling
- Graceful degradation
- Proper user feedback for errors
Exercise 9: User Interface Integration¶
Objective¶
Build a complete paginated search interface.
Tasks¶
- Pagination Controls
- Previous/Next buttons
- Page number navigation
-
Jump to page functionality
-
Loading States
- Show loading indicators
- Disable controls during requests
-
Progressive loading for infinite scroll
-
Accessibility Features
- Keyboard navigation
- Screen reader support
- Semantic HTML markup
Expected Results¶
- Complete, accessible pagination UI
- Smooth user experience
- Proper loading state management
Exercise 10: Production Deployment¶
Objective¶
Deploy pagination solution with monitoring and optimization.
Tasks¶
- Performance Monitoring
- Track pagination performance metrics
- Monitor error rates
-
Set up alerting for issues
-
A/B Testing
- Test different page sizes
- Compare pagination strategies
-
Measure user engagement
-
Optimization
- Implement based on usage patterns
- Optimize for common scenarios
- Scale for production load
Expected Results¶
- Production-ready pagination system
- Performance monitoring in place
- Data-driven optimization strategy
Validation Checklist¶
After completing the exercises, verify you can:
- [ ] Implement basic skip/top pagination
- [ ] Use field selection to optimize responses
- [ ] Add hit highlighting to search results
- [ ] Implement range-based pagination for large datasets
- [ ] Use search after pattern for deep pagination
- [ ] Combine multiple result shaping techniques
- [ ] Handle errors and edge cases gracefully
- [ ] Build accessible pagination interfaces
- [ ] Monitor and optimize pagination performance
- [ ] Deploy pagination solutions to production
Next Steps¶
After completing these exercises: 1. Review Troubleshooting for common issues 2. Explore Code Samples for implementation details 3. Move to Module 8: Search Explorer & Portal Tools 4. Consider advanced pagination patterns in intermediate modules
Additional Challenges¶
For advanced learners: - Implement cursor-based pagination for real-time data - Build infinite scroll with virtual scrolling - Create pagination with URL state management - Implement server-side pagination caching - Build pagination analytics and optimization