> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Search # Package: siteSearch # Namespace: SiteSearchPlatformizedService # Method link: https://dev.wix.com/docs/api-reference/business-management/site-search/wix-site-search/search.md ## Permission Scopes: Read Site Documents: SCOPE.SITE_SEARCH.ALL ## Introduction Retrieves a list of site documents that match the provided search query and optionally performs aggregations on the data queried. The Search API supports the document types listed in the [Introduction](https://dev.wix.com/docs/rest/business-management/search/wix-site-search/introduction.md), each with its own schema. These schemas define the fields available for filtering, sorting, and free-text searching. To learn more about working with the search query, see [API Query Language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md) and [Sorting and Paging](https://dev.wix.com/docs/rest/articles/getting-started/sorting-and-paging.md). --- ## REST API ### Schema ``` Method: search Description: Retrieves a list of site documents that match the provided search query and optionally performs aggregations on the data queried. The Search API supports the document types listed in the [Introduction](https://dev.wix.com/docs/rest/business-management/search/wix-site-search/introduction.md), each with its own schema. These schemas define the fields available for filtering, sorting, and free-text searching. To learn more about working with the search query, see [API Query Language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md) and [Sorting and Paging](https://dev.wix.com/docs/rest/articles/getting-started/sorting-and-paging.md). URL: https://www.wixapis.com/v1/search Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: search, documentType Method parameters: param name: documentType | type: DocumentType | required: true - enum: UNSPECIFIED - BLOG_POSTS - BOOKING_SERVICES - EVENTS - FORUM_CONTENT - ONLINE_PROGRAMS - PROGALLERY_ITEM - STORES_PRODUCTS - param name: language | type: language | description: Language to search in. param name: search | type: Search | required: true - name: paging | type: Paging | description: Paging options to limit and skip the number of items. - name: limit | type: integer | description: Number of items to load. - name: offset | type: integer | description: Number of items to skip in the current sort order. - name: filter | type: object | description: Filter object in the following format: `"filter" : { "fieldName1": "value1", "fieldName2":{"$operator":"value2"} }` Example of operators: `$eq`, `$ne`, `$lt`, `$lte`, `$gt`, `$gte`, `$in`, `$hasSome`, `$hasAll`, `$startsWith`, `$contains` - name: sort | type: array | description: Sort object in the following format: `[{"fieldName":"sortField1","order":"ASC"},{"fieldName":"sortField2","order":"DESC"}]` - name: fieldName | type: string | description: Name of the field to sort by. - name: order | type: SortOrder | description: Sort order. - enum: ASC, DESC - name: aggregations | type: array | description: A search method for grouping data into various categories (facets) and providing summaries for each category. For example, use aggregations to categorize search results by specific price ranges, brand names, or ratings. - ONE-OF: - name: value | type: ValueAggregation | description: Pass if `type` is `VALUE`. A value aggregation calculates metrics such as count for specific fields within a dataset, providing insights into the overall distribution and key statistics of those values. For example, use a value aggregation to get the number of products (count) for each price listed in the store. - name: limit | type: integer | description: Maximum number of aggregation results to return. Min: `1` Max: `250` Default: `10` - name: scalar | type: ScalarAggregation | description: Pass if `type` is `SCALAR`. A scalar aggregation calculates a single numerical value from a dataset, such as the total, minimum, or maximum value, summarizing the dataset into one key metric. For example, use a scalar aggregation to get the minimum price listed in a store. - name: type | type: ScalarType | description: Type of scalar aggregation. - enum: - MIN: Minimum value. - MAX: Maximum value. - name: nested | type: NestedAggregation | description: Pass if `type` is `NESTED`. A nested aggregation is applied to the results of another aggregation. Rather than aggregating directly on the primary dataset, first group data using one aggregation and then apply another aggregation within each group. This allows for more complex analyses that summarize data at different levels of detail or hierarchy. For example, to get the number of products that are in stock and out of stock for each price listed, first perform a value aggregation on the field containing the price, and a second value aggregation on the field indicating whether a product is in stock. You can nest up to a maximum of 3 aggregations. Each aggregation can be either value-based or scalar, allowing flexibility in how the data is grouped and analyzed. - name: nestedAggregations | type: array | description: List of aggregations, where each aggregation is nested within previous one. - ONE-OF: - name: value | type: ValueAggregation | description: Pass if `type` is `VALUE`. A value aggregation calculates metrics such as count for specific fields within a dataset, providing insights into the overall distribution and key statistics of those values. For example, use a value aggregation to get the number of products (count) for each price listed in the store. - name: scalar | type: ScalarAggregation | description: Pass if `type` is `SCALAR`. A scalar aggregation calculates a single numerical value from a dataset, such as the total, minimum, or maximum value, summarizing the dataset into one key metric. For example, use a scalar aggregation to get the minimum price listed in a store. - name: name | type: string | description: Aggregation name displayed in the return. - name: type | type: NestedAggregationType | description: Type of aggregation to perform. - enum: - VALUE: An aggregation where result buckets are dynamically built - one per unique value. - SCALAR: A single-value metric aggregation - e.g. min, max, sum, avg. - name: fieldPath | type: string | description: Field to aggregate by. - name: name | type: string | description: Aggregation name displayed in the return. - name: type | type: AggregationType | description: Type of aggregation to perform. - enum: - VALUE: An aggregation where result buckets are dynamically built - one per unique value. - SCALAR: A single-value metric aggregation - e.g. min, max, sum, avg. - NESTED: Multi-level aggregation, where each next aggregation is nested within previous one. - name: fieldPath | type: string | description: Field to aggregate by. - name: search | type: SearchDetails | description: Search information. - name: expression | type: string | description: Search term or expression. - name: fields | type: array | description: Fields to search in. If the array is empty, all fields are searched. - name: fuzzy | type: boolean | description: Whether to allow the search function to automatically correct typos or minor mistakes in the search expression. The search function uses an algorithm to find results that are close to the text provided. Return type: SearchResponse - ONE-OF: - name: pagingOffsetMetadata | type: PagingMetadata | description: Paging metadata. - name: count | type: integer | description: Number of items returned in the response. - name: offset | type: integer | description: Offset that was requested. - name: total | type: integer | description: Total number of items that match the query. - name: tooManyToCount | type: boolean | description: Whether the server failed to calculate the `total` field. - name: siteDocumentItems | type: array | description: Documents matching the search query. - name: id | type: string | description: Result GUID. - name: data | type: object | description: The document payload. - name: aggregationData | type: AggregationData | description: Aggregated data. - name: results | type: array | description: List of the aggregated data results. - ONE-OF: - name: values | type: ValueResults | description: Value aggregation results. - name: results | type: array | description: List of value aggregation results. - name: value | type: string | description: Value contained in the field specified in `fieldPath` for this aggregation in the request. - name: count | type: integer | description: Number of documents containing the specified value in the specified field. - name: scalar | type: ScalarResult | description: Scalar aggregation results. - name: type | type: ScalarType | description: Type of scalar aggregation. - enum: - MIN: Minimum value. - MAX: Maximum value. - name: value | type: number | description: Value of the scalar aggregation. For example, the minimum, maximum, or total value for the specified field. - name: nested | type: NestedResults | description: Nested aggregation results. - name: results | type: array | description: List of nested aggregation results. - name: results | type: Map | description: Aggregation results. - ONE-OF: - name: value | type: ValueResult | description: Value aggregation results. - name: value | type: string | description: Value contained in the field specified in `fieldPath` for this aggregation in the request. - name: count | type: integer | description: Number of documents containing the specified value in the specified field. - name: scalar | type: ScalarResult | description: Scalar aggregation results. - name: value | type: number | description: Scalar aggregation results. - name: name | type: string | description: Aggregation name defined in the request. - name: type | type: AggregationType | description: Type of aggregation that was performed. - enum: - VALUE: An aggregation where result buckets are dynamically built - one per unique value. - SCALAR: A single-value metric aggregation - e.g. min, max, sum, avg. - NESTED: Multi-level aggregation, where each next aggregation is nested within previous one. - name: fieldPath | type: string | description: Field the data was aggregated by. ``` ### Examples ### Aggregate store products by price ```curl curl -X POST \ 'https://www.wixapis.com/_api/site-search/v1/search' \ -H 'Content-type: application/json' \ -H 'Authorization: ' \ -d '{ "documentType": "STORES_PRODUCTS", "search": { "aggregations": [ { "name": "how-many-products-per-price", "fieldPath": "discountedPriceNumeric", "type": "VALUE", "value": {} } ], "sort": [], "paging": { "limit": 0 } } }' ``` ### Search 'game' in store products with a limit of 3 ```curl curl -X POST \ 'https://www.wixapis.com/_api/site-search/v1/search' \ -H 'Content-type: application/json' \ -H 'Authorization: ' \ -d '{ "documentType": "STORES_PRODUCTS", "search": { "aggregations": [], "sort": [], "search": { "fields": [], "expression": "game" }, "paging": { "limit": 3 } } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.siteSearch.SiteSearchPlatformizedService.search(search, options) Description: Retrieves a list of site documents that match the provided search query and optionally performs aggregations on the data queried. The Search API supports the document types listed in the [Introduction](https://dev.wix.com/docs/rest/business-management/search/wix-site-search/introduction.md), each with its own schema. These schemas define the fields available for filtering, sorting, and free-text searching. To learn more about working with the search query, see [API Query Language](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md) and [Sorting and Paging](https://dev.wix.com/docs/rest/articles/getting-started/sorting-and-paging.md). # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: search, options.documentType, options Method parameters: param name: options | type: SearchOptions none | required: true - name: documentType | type: DocumentType | description: Document type to search in. | required: true - enum: UNSPECIFIED, BLOG_POSTS, BOOKING_SERVICES, EVENTS, FORUM_CONTENT, ONLINE_PROGRAMS, PROGALLERY_ITEM, STORES_PRODUCTS - name: language | type: string | description: Language to search in. param name: search | type: Search | required: true - name: paging | type: Paging | description: Paging options to limit and skip the number of items. - name: limit | type: integer | description: Number of items to load. - name: offset | type: integer | description: Number of items to skip in the current sort order. - name: filter | type: object | description: Filter object in the following format: `"filter" : { "fieldName1": "value1", "fieldName2":{"$operator":"value2"} }` Example of operators: `$eq`, `$ne`, `$lt`, `$lte`, `$gt`, `$gte`, `$in`, `$hasSome`, `$hasAll`, `$startsWith`, `$contains` - name: sort | type: array | description: Sort object in the following format: `[{"fieldName":"sortField1","order":"ASC"},{"fieldName":"sortField2","order":"DESC"}]` - name: fieldName | type: string | description: Name of the field to sort by. - name: order | type: SortOrder | description: Sort order. - enum: ASC, DESC - name: aggregations | type: array | description: A search method for grouping data into various categories (facets) and providing summaries for each category. For example, use aggregations to categorize search results by specific price ranges, brand names, or ratings. - ONE-OF: - name: value | type: ValueAggregation | description: Pass if `type` is `VALUE`. A value aggregation calculates metrics such as count for specific fields within a dataset, providing insights into the overall distribution and key statistics of those values. For example, use a value aggregation to get the number of products (count) for each price listed in the store. - name: limit | type: integer | description: Maximum number of aggregation results to return. Min: `1` Max: `250` Default: `10` - name: scalar | type: ScalarAggregation | description: Pass if `type` is `SCALAR`. A scalar aggregation calculates a single numerical value from a dataset, such as the total, minimum, or maximum value, summarizing the dataset into one key metric. For example, use a scalar aggregation to get the minimum price listed in a store. - name: type | type: ScalarType | description: Type of scalar aggregation. - enum: - MIN: Minimum value. - MAX: Maximum value. - name: nested | type: NestedAggregation | description: Pass if `type` is `NESTED`. A nested aggregation is applied to the results of another aggregation. Rather than aggregating directly on the primary dataset, first group data using one aggregation and then apply another aggregation within each group. This allows for more complex analyses that summarize data at different levels of detail or hierarchy. For example, to get the number of products that are in stock and out of stock for each price listed, first perform a value aggregation on the field containing the price, and a second value aggregation on the field indicating whether a product is in stock. You can nest up to a maximum of 3 aggregations. Each aggregation can be either value-based or scalar, allowing flexibility in how the data is grouped and analyzed. - name: nestedAggregations | type: array | description: List of aggregations, where each aggregation is nested within previous one. - ONE-OF: - name: value | type: ValueAggregation | description: Pass if `type` is `VALUE`. A value aggregation calculates metrics such as count for specific fields within a dataset, providing insights into the overall distribution and key statistics of those values. For example, use a value aggregation to get the number of products (count) for each price listed in the store. - name: scalar | type: ScalarAggregation | description: Pass if `type` is `SCALAR`. A scalar aggregation calculates a single numerical value from a dataset, such as the total, minimum, or maximum value, summarizing the dataset into one key metric. For example, use a scalar aggregation to get the minimum price listed in a store. - name: name | type: string | description: Aggregation name displayed in the return. - name: type | type: NestedAggregationType | description: Type of aggregation to perform. - enum: - VALUE: An aggregation where result buckets are dynamically built - one per unique value. - SCALAR: A single-value metric aggregation - e.g. min, max, sum, avg. - name: fieldPath | type: string | description: Field to aggregate by. - name: name | type: string | description: Aggregation name displayed in the return. - name: type | type: AggregationType | description: Type of aggregation to perform. - enum: - VALUE: An aggregation where result buckets are dynamically built - one per unique value. - SCALAR: A single-value metric aggregation - e.g. min, max, sum, avg. - NESTED: Multi-level aggregation, where each next aggregation is nested within previous one. - name: fieldPath | type: string | description: Field to aggregate by. - name: search | type: SearchDetails | description: Search information. - name: expression | type: string | description: Search term or expression. - name: fields | type: array | description: Fields to search in. If the array is empty, all fields are searched. - name: fuzzy | type: boolean | description: Whether to allow the search function to automatically correct typos or minor mistakes in the search expression. The search function uses an algorithm to find results that are close to the text provided. Return type: PROMISE - ONE-OF: - name: pagingOffsetMetadata | type: PagingMetadata | description: Paging metadata. - name: count | type: integer | description: Number of items returned in the response. - name: offset | type: integer | description: Offset that was requested. - name: total | type: integer | description: Total number of items that match the query. - name: tooManyToCount | type: boolean | description: Whether the server failed to calculate the `total` field. - name: siteDocumentItems | type: array | description: Documents matching the search query. - name: _id | type: string | description: Result GUID. - name: data | type: object | description: The document payload. - name: aggregationData | type: AggregationData | description: Aggregated data. - name: results | type: array | description: List of the aggregated data results. - ONE-OF: - name: values | type: ValueResults | description: Value aggregation results. - name: results | type: array | description: List of value aggregation results. - name: value | type: string | description: Value contained in the field specified in `fieldPath` for this aggregation in the request. - name: count | type: integer | description: Number of documents containing the specified value in the specified field. - name: scalar | type: ScalarResult | description: Scalar aggregation results. - name: type | type: ScalarType | description: Type of scalar aggregation. - enum: - MIN: Minimum value. - MAX: Maximum value. - name: value | type: number | description: Value of the scalar aggregation. For example, the minimum, maximum, or total value for the specified field. - name: nested | type: NestedResults | description: Nested aggregation results. - name: results | type: array | description: List of nested aggregation results. - name: results | type: Map | description: Aggregation results. - ONE-OF: - name: value | type: ValueResult | description: Value aggregation results. - name: value | type: string | description: Value contained in the field specified in `fieldPath` for this aggregation in the request. - name: count | type: integer | description: Number of documents containing the specified value in the specified field. - name: scalar | type: ScalarResult | description: Scalar aggregation results. - name: value | type: number | description: Scalar aggregation results. - name: name | type: string | description: Aggregation name defined in the request. - name: type | type: AggregationType | description: Type of aggregation that was performed. - enum: - VALUE: An aggregation where result buckets are dynamically built - one per unique value. - SCALAR: A single-value metric aggregation - e.g. min, max, sum, avg. - NESTED: Multi-level aggregation, where each next aggregation is nested within previous one. - name: fieldPath | type: string | description: Field the data was aggregated by. ``` ### Examples ### search ```javascript import { wixSiteSearch } from '@wix/search'; async function search(search,options) { const response = await wixSiteSearch.search(search,options); }; ``` ### search (with elevated permissions) ```javascript import { wixSiteSearch } from '@wix/search'; import { auth } from '@wix/essentials'; async function mySearchMethod(search,options) { const elevatedSearch = auth.elevate(wixSiteSearch.search); const response = await elevatedSearch(search,options); } ``` ### search (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { wixSiteSearch } from '@wix/search'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { wixSiteSearch }, // Include the auth strategy and host as relevant }); async function search(search,options) { const response = await myWixClient.wixSiteSearch.search(search,options); }; ``` ---