Elasticsearch Overview
Overview
Section titled βOverviewβThis documentation covers a complete Elasticsearch integration for a WordPress-based product catalog system. The integration provides advanced Lithuanian language search capabilities for 60,000+ products with real-time synchronization, comprehensive monitoring, and automated management.
Key Features
Section titled βKey Featuresβπ Advanced Search Capabilities
Section titled βπ Advanced Search Capabilitiesβ- Lithuanian Language Support: Custom analyzer with snowball stemming
- Full-Text Search: Multi-field search across title, brand, description
- Fuzzy Matching: Typo-tolerant search with configurable fuzziness
- Advanced Filtering: Category, brand, price range, availability filters
β‘ Performance & Scalability
Section titled ββ‘ Performance & Scalabilityβ- 60,000+ Products: Optimized for large datasets
- Real-time Sync: Automated synchronization with PostgreSQL
- Batch Processing: Efficient bulk indexing operations
- Sub-second Response: Fast search query performance
π οΈ Management & Monitoring
Section titled βπ οΈ Management & Monitoringβ- Real-time Console: Comprehensive monitoring dashboard
- Progress Tracking: ETA calculations and sync status
- Error Recovery: Automatic failed batch handling
- Log Management: Detailed logging and troubleshooting
π§ Integration Features
Section titled βπ§ Integration Featuresβ- WordPress Native: Seamless WordPress integration
- AJAX Endpoints: Dynamic frontend interactions
- Admin Dashboard: User-friendly management interface
- Cron Automation: Scheduled synchronization tasks
Architecture Overview
Section titled βArchitecture OverviewβThe Elasticsearch integration follows a clean separation of concerns with three main layers:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ User Interface Layer ββββββββββββββββββββββββ¬ββββββββββββββββββββββ¬ββββββββββββββββββ€β Search Page β Monitoring Console β Admin Panel ββ (page-search.php) β (console.php) β (WordPress) ββββββββββββββββββββββββ΄ββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ WordPress Integration ββββββββββββββββββββββββ¬ββββββββββββββββββββββ¬ββββββββββββββββββ€β AJAX Handlers β Template System β Hook System ββ (functions.php) β (page templates) β (WordPress) ββββββββββββββββββββββββ΄ββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Business Logic Layer ββββββββββββββββββββββββ¬ββββββββββββββββββββββ¬ββββββββββββββββββ€β Elasticsearch β Console Manager β Sync Manager ββ Client β (Display Only) β (CLI/Cron) ββββββββββββββββββββββββ΄ββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ Data Storage Layer ββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββ€β PostgreSQL β Elasticsearch ββ (Source Data) β (Search Index) ββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββKey Design Principles
Section titled βKey Design Principlesβ1. Clean Separation
Section titled β1. Clean Separationβ- CLI/cron operations separate from WordPress display operations
- Business logic isolated from presentation layer
- Database operations abstracted from search operations
2. Fail-Safe Architecture
Section titled β2. Fail-Safe Architectureβ- Robust error handling and automatic recovery mechanisms
- Failed batch tracking and automatic skipping
- Connection timeout and retry handling
3. Performance Optimization
Section titled β3. Performance Optimizationβ- Optimized for large datasets (60k+ products)
- Batch processing with configurable sizes
- Memory management and garbage collection
4. Comprehensive Monitoring
Section titled β4. Comprehensive Monitoringβ- Real-time progress tracking
- Performance metrics and ETA calculations
- Detailed logging and error reporting
5. Language Support
Section titled β5. Language Supportβ- Native Lithuanian language analysis and search
- Custom analyzers with snowball stemming
- Multi-language text processing capabilities
System Requirements
Section titled βSystem RequirementsβServer Requirements
Section titled βServer Requirementsβ- PHP: 8.0+ with PostgreSQL and cURL extensions
- PostgreSQL: 13+ with read/write access
- Elasticsearch: 7.x running and accessible
- WordPress: 6.x with custom theme support
Network Requirements
Section titled βNetwork Requirementsβ- Elasticsearch Server:
91.99.113.45:9200 - Database Server:
162.55.174.116:5432 - Web Server: HTTP/HTTPS access for WordPress
Storage Requirements
Section titled βStorage Requirementsβ- Index Storage: ~2GB for 60k products
- Log Storage: ~100MB for operation logs
- State Files: ~1MB for sync state persistence
Quick Start
Section titled βQuick Startβ1. Basic Setup
Section titled β1. Basic Setupβ# Deploy core filescp inc/elasticsearch*.php /wp-content/themes/products/inc/cp scripts/elasticsearch-auto-sync.php /wp-content/themes/products/scripts/2. Database Configuration
Section titled β2. Database ConfigurationβALTER TABLE product ADD COLUMN added_search BOOLEAN DEFAULT FALSE;CREATE INDEX idx_product_added_search ON product(added_search);3. Cron Setup
Section titled β3. Cron Setupβ# Add to crontab*/15 * * * * /usr/bin/php /path/to/elasticsearch-auto-sync.php4. WordPress Pages
Section titled β4. WordPress Pagesβ- Create page with βSearch Pageβ template
- Create page with βElasticsearch Consoleβ template
Whatβs Next
Section titled βWhatβs Nextβ- Architecture - Detailed system architecture
- Core Components - Key classes and functions
- Database Integration - PostgreSQL integration
- WordPress Integration - WordPress-specific features
- Search Functionality - Search implementation
- Monitoring & Management - Console and monitoring
- Deployment - Installation and setup