---
title: "Search Item Segments"
method: POST
path: "/{databaseId}/search/users/{userId}/item-segments/"
tags: ["Search"]
---

# Search Item Segments

`POST /{databaseId}/search/users/{userId}/item-segments/`

Full-text personalized search that returns Segments from a Segmentation. The results are based on the provided `searchQuery` and also on the user's past interactions (purchases, ratings, etc.).

Based on the used Segmentation, this endpoint can be used for example for:

  - Searching within categories or brands
  - Searching within genres or artists

For example if the user is searching for "iPhone" this endpoint can return "cell phones" category.

You need to set the used Segmentation the Admin UI in the Scenario settings prior to using this endpoint.

The returned segments are sorted by relevance (first segment being the most relevant).

It is also possible to use POST HTTP method (for example in case of very long ReQL filter) - query parameters then become body parameters.

## Path parameters

- `databaseId` string, required
- `userId` string, required

## Request body

- SearchItemSegmentsParameters
  - `searchQuery` string, required — Search query provided by the user. It is used for the full-text search.
  - `count` integer, required — Number of segments to be returned (N for the top-N results).
  - `scenario` string — Scenario defines a particular application of recommendations. It can be, for example, "homepage", "cart", or "emailing". You can set various settings to the [scenario](https://docs.recombee.com/scenarios) in the [Admin UI](https://admin.recombee.com). You can also see the performance of each scenario in the Admin UI separately, so you can check how well each application performs. The AI that optimizes models to get the best results may optimize different scenarios separately or even use different models in each of the scenarios.
  - `cascadeCreate` boolean — If the user does not exist in the database, returns a list of non-personalized recommendations and creates the user in the database. This allows, for example, rotations in the following recommendations for that user, as the user will be already known to the system.
  - `filter` string — Boolean-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to filter recommended segments based on the `segmentationId`.
  - `booster` string — Number-returning [ReQL](https://docs.recombee.com/reql) expression which allows you to boost recommendation rate of some segments based on the `segmentationId`.
  - `logic` union
    - string
    - object
      - `name` string — Name of the logic that should be used
      - `settings` object — Parameters passed to the logic
  - `expertSettings` object — Dictionary of custom options.
  - `returnAbGroup` boolean — If there is a custom AB-testing running, return the name of the group to which the request belongs.
  - `reqlExpressions` object — A dictionary of [ReQL](https://docs.recombee.com/reql) expressions that will be executed for each recommended Item Segment. This can be used to compute additional properties of the recommended Item Segments. The keys are the names of the expressions, and the values are the actual ReQL expressions. Example request: ```json { "reqlExpressions": { "countItems": "size(segment_items(\"categories\", 'segmentId'))" } } ``` Example response: ```json { "recommId": "a7ac55a4-8d6e-4f19-addc-abac4164d8a8", "recomms": [ { "id": "category-fantasy-books", "reqlEvaluations": { "countItems": 486 } }, { "id": "category-sci-fi-costumes", "reqlEvaluations": { "countItems": 19 } } ], "numberNextRecommsCalls": 0 } ```

## Response `200`

successful operation

- SearchResponse
  - `recommId` string, required — Id of the personalized search request
  - `recomms` Recommendation[], required — Results of the personalized search
    - `id` string, required — Id of the recommended item
    - `values` object — Property values of the recommended item
    - `reqlEvaluations` object — Dictionary of evaluated ReQL expressions specified in the request and calculated for the recommended item. The keys are the names of the ReQL expressions, and the values are the results of the evaluations.
  - `numberNextRecommsCalls` integer — How many times *Recommend Next Items* have been called for this `recommId`
  - `abGroup` string — Name of AB-testing group to which the request belongs if there is a custom AB-testing running.

## Other responses

- `400` — userId does not match ^[a-zA-Z0-9_\-:@\.]+$, count is not a positive integer, searchQuery is not provided, filter or booster is not valid [ReQL](https://docs.recombee.com/reql) expressions, filter expression does not return boolean, booster does not return double or integer.
- `404` — userId not found in the database and cascadeCreate is false. If there is no additional info in the JSON response, you probably have an error in your URL.

---

[API](https://skmtc.dev/recombee/apis/recombee-api.md) · [All operations](https://skmtc.dev/recombee/apis/recombee-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/recombee/recombee-api/revisions/a9c9c33eb2e8/schema)
