Prerequisites
- A Marqo Cloud account
- Your Marqo index ID (used for the
x-marqo-index-idheader) - An existing ecommerce index with products (add products guide)
Search Requests
Search requests are made via aPOST /search request with a search body containing your query and search parameters.
Example
{index_name} with your actual index name and {index_id} with the ID provided for your ecommerce deployment.
Response
Search Parameters
Here is a full list of parameters available for/search:
| Parameter | Type | Default | Description |
|---|---|---|---|
q | String | null | Query string for product search |
limit | Integer | 10 | Maximum number of products to return |
offset | Integer | 0 | Number of products to skip (for pagination) |
filter | String | null | Filter string using Marqo’s query DSL to narrow search results |
attributesToRetrieve | Array of strings | ["productTitle", "variantTitle", "price", "variantImageUrl", "collections", "_id", "_score"] | Specific product fields to return. If not specified, returns the default core product fields |
facets | Object | null | Facet configuration for aggregated results |
sortBy | Object | null | Sort configuration for results ordering |
profileId | String | null | (optional) The ID of a named configuration profile to use for the request. Profiles allow fine-tuned configurations tailored to specific use cases. If the specified profile does not exist, Marqo will fallback to the default configuration. Please contact your Marqo representative to set up profiles for your requirements. Example: summer-sale-2026 |
userId | String | null | User ID for personalization |
sessionId | String | null | Session ID for personalization |
Filtering
You can use Marqo’s filter string DSL to refine search results. Filter strings can be used with all search methods and use a syntax based on Lucene with some differences. For complete filter syntax and examples, see our Filter DSL Guide.Key Filter Features
- Fielded searches - All term filters must be connected to a field, e.g.,
brand:Nike - Range filters - Efficient range filters for numeric types, e.g.,
price:[50 TO 300] - Boolean operators - Support for AND, OR, NOT with proper grouping
- Array filtering - Filter over array fields like collections or tags
Examples
Common Filter Patterns
| Filter Type | Example | Description |
|---|---|---|
| Price Range | price:[50 TO 300] | Products between 300 |
| Open Range | price:[100 TO *] | Products $100 and above |
| Exact Match | brand:Nike | Products with exact brand match |
| Boolean | is_available:true | Products that are available |
| Array Contains | collections:electronics | Products in electronics collection |
| Logical AND | brand:Nike AND price:[* TO 200] | Nike products under $200 |
| Logical OR | brand:(Nike OR Adidas) | Products from either brand |
| Complex Expression | (brand:Nike AND collections:athletic) OR (price:[* TO 50] AND is_sale:true) | Nike athletic items OR sale items under $50 |
| NOT Operator | collections:electronics AND NOT brand:Apple | Electronics excluding Apple products |
Faceted Search
Facets allow you to aggregate data from your documents based on specific fields. This can be useful for creating filters, showing data distributions, or implementing drill-down search functionality.Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
fields | Object | null | Fields to facet on and their configuration |
maxResults | Integer | 100 | Maximum facet results per field (max: 10000) |
maxDepth | Integer | null | Max documents to consider for aggregation |
order | String | "desc" | Order of facet results: asc or desc |
Field Parameters
| Parameter | Type | Description |
|---|---|---|
type | String | Facet type: string, number, or array |
ranges | Array | For numeric fields: define value ranges |
excludeTerms | Array | Exclude specific terms from this facet |
Range Parameters (Numeric Fields)
| Parameter | Type | Default | Description |
|---|---|---|---|
from | Number | null | Lower bound (inclusive), -Inf if not specified |
to | Number | null | Upper bound (exclusive), Inf if not specified |
name | String | null | Custom range name (defaults to “from:to”) |
Examples
Response
Sorting
sortBy allows you to sort the search results based on specific numerical fields. This can be useful for ordering results by price, rating, or any other numerical attribute.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
fields | List[Dict] | No default | A list of fields to be sorted on, with sort order and missing policy |
sortDepth | Integer | null | The number of documents to be sorted in the global phase |
minSortCandidates | Integer | null | The minimum number of documents to be sorted on |
Field Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
fieldName | String | No default | The field to be sorted on |
order | String | "desc" | The sort order: "desc" or "asc" |
missing | String | "last" | Missing value policy: "first" or "last" |
Examples
Pagination
Handle large result sets with pagination usinglimit and offset parameters.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
limit | Integer | 10 | Maximum number of documents to return |
offset | Integer | 0 | Number of documents to skip |
Examples
Search as You Type
Search as you type provides real-time search results as users input queries, creating an instant and responsive search experience. This feature leverages the same search endpoint with optimized parameters for real-time performance.Implementation
Use the standard search endpoint with these considerations for optimal real-time performance:- Lower limits: Use smaller
limitvalues (5-10) for faster response times - Minimal attributes: Only retrieve essential fields using
attributesToRetrieve - Client-side debouncing: Implement 200-300ms delays between requests
- Minimum query length: Consider requiring 2-3 characters before triggering search
Example
Best Practices
- Debouncing: Implement client-side delays to prevent excessive API calls
- Progressive loading: Start with minimal results and allow expansion
- Caching: Cache recent results to improve perceived performance
- Error handling: Gracefully handle timeouts and network issues
- Accessibility: Ensure screen readers can navigate real-time results
Composite Search
Composite search enables multi-term queries where each search term can have a different weight.Example
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
weightedQuery | Object | required | Multi-term query as key-value pairs where keys are search terms and values are weights |
originalQuery | String | null | The original user query string. Include this if the user entered a single string that was transformed into the weightedQuery |
limit | Integer | 10 | Maximum number of products to return |
offset | Integer | 0 | Number of products to skip (for pagination) |
filter | String | null | Filter string using Marqo’s query DSL |
attributesToRetrieve | Array of strings | Default fields | Specific product fields to return |
facets | Object | null | Facet configuration for aggregated results |
profileId | String | null | (optional) The ID of a named configuration profile to use for the request. Profiles allow fine-tuned configurations tailored to specific use cases. If the specified profile does not exist, Marqo will fallback to the default configuration. Please contact your Marqo representative to set up profiles for your requirements. Example: summer-sale-2026 |