Search Products (Elasticsearch)
Intelligent, multilingual, typo-tolerant product search powered by Elasticsearch. Public endpoint.
Endpoint
Authentication
Not required (public endpoint)
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
q |
string | No | Search query (searches in product names, descriptions, SKU, category, brand) |
lang |
string | No | Language code for search ("az", "en", "es", "de"). Defaults to "en" |
page |
integer | No | Page number (starts at 1). Defaults to 1 |
size |
integer | No | Items per page (1-100). Defaults to 20 |
currency_id |
integer | No | Currency ID for price conversion |
category_id |
integer | No | Filter by category ID |
store_id |
integer | No | Filter by store ID |
min_price |
float | No | Minimum price filter |
max_price |
float | No | Maximum price filter |
Response
Success (200 OK)
{
"data": [
{
"id": 1,
"product_id": 5,
"product": {...},
"name_az": "Məhsul Adı",
"name_en": "Product Name",
"name_es": "Nombre del Producto",
"name_de": "Produktname",
"sku": "SKU-001",
"stock_quantity": 100,
"price": 29.99,
"discount_percent": 10.0,
"discount_price": 26.99,
"currency_name": "AZN",
"attributes": [...],
"images": [...],
"is_wish": false,
"created": "2025-01-15T10:30:00Z"
}
],
"count": 25,
"page": 1,
"size": 20
}
Error Responses
Search Service Unavailable (503)
Search Failed (500)
Example Requests
Basic Search
Search with Filters
curl -X GET "https://api.luxmart.site/v1/products/search/?q=phone&category_id=5&min_price=100&max_price=1000&store_id=3¤cy_id=1&lang=az"
Search with JavaScript (Fetch)
const searchProducts = async (query, lang = 'en', page = 1, size = 20) => {
const params = new URLSearchParams({
q: query,
lang,
page: page.toString(),
size: size.toString()
});
const response = await fetch(
`https://api.luxmart.site/v1/products/search/?${params}`
);
return await response.json();
};
// Usage
const results = await searchProducts('laptop', 'en', 1, 20);
console.log(results);
Search with Axios
import axios from 'axios';
const searchProducts = async (query, options = {}) => {
const {
lang = 'en',
page = 1,
size = 20,
currency_id,
category_id,
store_id,
min_price,
max_price
} = options;
const params = {
q: query,
lang,
page,
size
};
if (currency_id) params.currency_id = currency_id;
if (category_id) params.category_id = category_id;
if (store_id) params.store_id = store_id;
if (min_price) params.min_price = min_price;
if (max_price) params.max_price = max_price;
const response = await axios.get(
'https://api.luxmart.site/v1/products/search/',
{ params }
);
return response.data;
};
// Usage
const results = await searchProducts('laptop', {
lang: 'en',
page: 1,
size: 20,
category_id: 5,
min_price: 100,
max_price: 1000
});
Features
Multilingual Search
- Searches across all supported languages (az, en, es, de)
- Language-specific analyzers for better matching
- Results include translations for all languages
Typo Tolerance
- Fuzzy matching handles common typos and misspellings
- Automatic stemming for better word matching
- ASCII folding for accent-insensitive search
Advanced Filtering
- Filter by category, store, or price range
- Multiple filters can be combined
- Filters are applied after search matching
Relevance Scoring
- Results are ranked by relevance to the search query
- Product names have higher weight than descriptions
- Exact matches are prioritized
Notes
- Empty Query: If
qis empty or not provided, all products matching the filters are returned - Language Support: The
langparameter affects search matching but results include all language translations - Pagination: Use
pageandsizefor pagination. Maximumsizeis 100 - Price Filtering:
min_priceandmax_pricefilter by the product's base price - Currency Conversion: If
currency_idis provided, prices are converted to the specified currency - Wishlist Status:
is_wishindicates if the product is in the user's wishlist (requires authentication header) - Search Fields: The search query matches against:
- Product names (all languages)
- Product descriptions (all languages)
- SKU
- Category name
- Brand name
- Index Status: If the Elasticsearch index doesn't exist, an empty result set is returned (no error)
- Performance: Search is optimized for fast response times, typically under 100ms
- Auto-indexing: Products are automatically indexed when created, updated, or deleted
Related Endpoints
- Sync Products to Elasticsearch - Manually sync all products to Elasticsearch
- Filter Products - Advanced filtering without Elasticsearch
- Search Products By Store - Store-specific search