> ## Documentation Index
> Fetch the complete documentation index at: https://twigz.arqqin.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Search System

> Understanding the search and discovery features

# Search System

Twigz provides powerful search capabilities for products, stores, and content discovery.

## Search Types

### 1. **Product Search**

* Full-text search across product names and descriptions
* Category-based filtering
* Price range filtering
* Store-specific search

### 2. **Store Search**

* Search by store name and description
* Location-based search
* Category filtering
* Rating and review filtering

### 3. **Quick Search**

* Fast autocomplete suggestions
* Recent search history
* Popular searches
* Typo tolerance

### 4. **Advanced Search**

* Multiple filters and criteria
* Boolean search operators
* Faceted search
* Sorting options

## Search Implementation

### Basic Search

```typescript theme={null}
// Search products
const results = await convex.query(api.shared.search.search, {
  query: "coffee beans",
  filters: {
    category: "food",
    priceRange: { min: 10, max: 50 }
  }
});
```

### Quick Search

```typescript theme={null}
// Get search suggestions
const suggestions = await convex.query(api.shared.search.quickSearch, {
  query: "cof",
  limit: 5
});
```

### Advanced Search

```typescript theme={null}
// Complex search with multiple criteria
const results = await convex.query(api.shared.search.advancedSearch, {
  query: "organic coffee",
  filters: {
    category: "food",
    storeId: "store_123",
    priceRange: { min: 15, max: 100 },
    rating: { min: 4.0 }
  },
  sortBy: "price",
  sortOrder: "asc"
});
```

## Search Features

### Search History

* Track user search queries
* Personalized recommendations
* Search analytics

### Search Analytics

* Popular search terms
* Search success rates
* User behavior insights

### Search Optimization

* Indexing for fast retrieval
* Relevance scoring
* Search result ranking

## Search API Functions

| Function             | Description                           |
| -------------------- | ------------------------------------- |
| `search`             | Main search function with filters     |
| `quickSearch`        | Fast autocomplete suggestions         |
| `advancedSearch`     | Complex search with multiple criteria |
| `saveSearchHistory`  | Save user search queries              |
| `getSearchHistory`   | Retrieve user search history          |
| `clearSearchHistory` | Clear user search history             |

## Best Practices

1. **Indexing**: Ensure all searchable content is properly indexed
2. **Performance**: Use pagination for large result sets
3. **Relevance**: Implement proper relevance scoring
4. **User Experience**: Provide clear search feedback
5. **Analytics**: Track search performance and user behavior

<Note>
  The search system is optimized for fast, relevant results with support for complex filtering and sorting.
</Note>
