PHPackages                             prestoworld/search-engine - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. prestoworld/search-engine

ActiveLibrary[Search &amp; Filtering](/categories/search)

prestoworld/search-engine
=========================

🚀 High-Performance Search Infrastructure for PrestoWorld CMS

05PHP

Since Feb 26Pushed 2mo agoCompare

[ Source](https://github.com/PrestoWorld/search-engine)[ Packagist](https://packagist.org/packages/prestoworld/search-engine)[ RSS](/packages/prestoworld-search-engine/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PrestoWorld Search Engine
=========================

[](#prestoworld-search-engine)

[![Latest Version](https://camo.githubusercontent.com/4dda12e9ecbf41e008157bb333bf6b5dfc34fc28859f6c11d7e6d9bf89f9ce85/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f70726573746f776f726c642f7365617263682d656e67696e652e737667)](https://github.com/prestoworld/search-engine/releases)[![License](https://camo.githubusercontent.com/829514e7c09326e2232163c77e62e778ea5e7b09374138d78c9778552802f293/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f70726573746f776f726c642f7365617263682d656e67696e652e737667)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/acffb6ae1962992d26e4466782832787e79504a6250f80d732c4283458b9f497/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c75652e737667)](https://php.net)

### 🚀 High-Performance Search Infrastructure for PrestoWorld CMS

[](#-high-performance-search-infrastructure-for-prestoworld-cms)

The **PrestoWorld Search Engine** is the foundational search layer for the PrestoWorld ecosystem. Engineered for speed, precision, and scalability, this module replaces traditional database lookup methods with a sophisticated indexing and retrieval system designed specifically for the modern web.

---

✨ Why PrestoWorld Search?
-------------------------

[](#-why-prestoworld-search)

In a data-driven world, finding content should be instantaneous and intelligent. The PrestoWorld Search Engine moves beyond simple pattern matching to provide a robust architectural framework that understands your data.

- **🔧 Flexible Adapter System**: Switch between TNTSearch, Typesense, Meilisearch, or custom engines without code changes
- **⚡ Lightning Performance**: Optimized indexing algorithms that deliver results in milliseconds, even with massive datasets
- **🎯 Advanced Query Builder**: Fluent interface for complex searches with filters, sorting, and faceted navigation
- **🔍 Full-Text Search**: Deep data indexing with fuzzy matching, highlighting, and relevance scoring
- **📊 Real-time Analytics**: Built-in performance monitoring and search analytics
- **🎨 UI Integration**: Automatic form generation and faceted navigation components
- **🛡️ Production Ready**: Comprehensive error handling, caching, and security features

---

🚀 Quick Start
-------------

[](#-quick-start)

### Installation

[](#installation)

```
composer require prestoworld/search-engine
```

### Basic Setup

[](#basic-setup)

1. **Configure Environment**Add settings to `.env`:

```
SEARCH_ENGINE=meilisearch
MEILISEARCH_URL=http://localhost:7700
```

2. **Index Your Data**

```
php witals search:index posts --source="App\Models\Post"
```

### Your First Search

[](#your-first-search)

```
use Prestoworld\SearchEngine\SearchManager;
use Prestoworld\SearchEngine\QueryBuilder\SearchQueryBuilder;

// Simple search using manager
$searchManager = app(SearchManager::class);
$results = $searchManager->search('articles', 'search query');

// Advanced search with Query Builder
$results = SearchQueryBuilder::for('products')
    ->query('laptop')
    ->where('status', 'active')
    ->paginate(12);
```

---

🎯 Key Features
--------------

[](#-key-features)

### 🔧 Multi-Adapter Support

[](#-multi-adapter-support)

Switch between search engines instantly:

```
$searchManager = app(SearchManager::class);

// Use TNTSearch for file-based search
$searchManager->switchAdapter('tntsearch');

// Use Typesense for typo-tolerant search
$searchManager->switchAdapter('typesense');

// Use Meilisearch for lightning-fast search
$searchManager->switchAdapter('meilisearch');
```

### 🔍 Advanced Query Builder

[](#-advanced-query-builder)

Build complex searches with a fluent interface:

```
$results = SearchQueryBuilder::for('products')
    ->query('smartphone')
    ->where('category', 'electronics')
    ->whereIn('brand', ['Apple', 'Samsung'])
    ->whereBetween('price', 500, 1500)
    ->whereLike('features', 'camera')
    ->orderBy('rating', 'desc')
    ->orderBy('price', 'asc')
    ->limit(20)
    ->get();
```

### 🎛️ Comprehensive Filtering

[](#️-comprehensive-filtering)

Advanced filtering system with multiple filter types:

```
$filters = FilterManager::fromRequest()
    ->text('title')                    // Text search
    ->select('category')                // Dropdown selection
    ->multiSelect('tags')               // Multiple selections
    ->range('price', 100, 1000)        // Price range
    ->dateRange('created_at')           // Date range
    ->boolean('featured')               // Yes/No filter
    ->exists('image');                  // Has image or not
```

### 📊 Faceted Search &amp; Aggregations

[](#-faceted-search--aggregations)

Build sophisticated faceted navigation:

```
$facets = FacetManager::for('products')
    ->facet('category', ['label' => 'Categories'])
    ->facet('brand', ['label' => 'Brands'])
    ->rangeFacet('price', [
        ['from' => 0, 'to' => 50, 'label' => 'Under $50'],
        ['from' => 50, 'to' => 100, 'label' => '$50-$100'],
        ['from' => 100, 'label' => 'Over $100']
    ])
    ->getFacets('laptop');
```

### 🎨 Form Integration

[](#-form-integration)

Auto-generate search forms with all features:

```
$form = SearchForm::create('/search')
    ->queryField('q')
    ->textFilter('title')
    ->selectFilter('category', $categories)
    ->rangeFilter('price')
    ->sortSelect([
        'relevance' => 'Relevance',
        'price_asc' => 'Price: Low to High'
    ]);

echo $form->render();
```

---

📖 Documentation
---------------

[](#-documentation)

### 📚 Essential Reading

[](#-essential-reading)

- **[USAGE.md](USAGE.md)** - Complete usage guide with examples
- **[DESIGN.md](DESIGN.md)** - Architecture and design patterns
- **[EXAMPLES.md](EXAMPLES.md)** - Comprehensive code examples

### 🔧 Configuration

[](#-configuration)

#### Search Engines

[](#search-engines)

EngineBest ForPerformanceFeatures**TNTSearch**Small datasets (&lt;100K docs)⚡⚡File-based, PHP-native**Typesense**User-facing search⚡⚡⚡Typo-tolerant, fast**Meilisearch**High-performance needs⚡⚡⚡⚡Lightning-fast, real-time#### Environment Variables

[](#environment-variables)

```
# General
SEARCH_ENGINE=meilisearch
SEARCH_CACHE_ENABLED=true
SEARCH_BATCH_SIZE=1000

# TNTSearch
SEARCH_STORAGE_PATH=/app/storage/search

# Typesense
TYPESENSE_API_KEY=xyz
TYPESENSE_HOST=localhost
TYPESENSE_PORT=8108

# Meilisearch
MEILISEARCH_URL=http://localhost:7700
MEILISEARCH_API_KEY=xyz
```

---

🛠️ Real-World Examples
----------------------

[](#️-real-world-examples)

### E-commerce Product Search

[](#e-commerce-product-search)

```
class ProductSearchController extends Controller
{
    public function search(Request $request)
    {
        // Build complex product search
        $results = SearchQueryBuilder::for('products')
            ->query($request->get('q'))
            ->where('status', 'active')
            ->where('stock', '>', 0)
            ->applyFilters($request)
            ->applySorting($request)
            ->paginate(12);

        // Get faceted navigation
        $facets = FacetManager::for('products')
            ->fromRequest()
            ->facet('category')
            ->facet('brand')
            ->rangeFacet('price')
            ->getFacets($request->get('q', '*'));

        return view('products.search', [
            'products' => $results,
            'facets' => $facets,
            'form' => $this->getSearchForm(),
        ]);
    }
}
```

### Blog Article Search

[](#blog-article-search)

```
class BlogController extends Controller
{
    public function search(Request $request)
    {
        $results = SearchQueryBuilder::for('articles')
            ->query($request->get('q'))
            ->where('status', 'published')
            ->where('published_at', '
