---
title: "Create search view"
method: POST
path: "/_fabric/{fabric}/_api/search/view"
tags: ["Search"]
---

# Create search view

`POST /_fabric/{fabric}/_api/search/view`

## Request

- The document declares no server URL.
- Auth: one of:
  - API key in header `Authorization`
  - HTTP bearer
- TypeScript: <https://skmtc.dev/macrometa/apis/macrometa-api-reference/docs/_fabric/:fabric/_api/search/view/post.ts> (a function with typed inputs; its response is checked against the schema)

Create a search view. Search view is updated with collection data changes every 10 seconds.

**Note**: Search view can't be created with the links. Use PUT/PATCH for links management.

## Path parameters

- `fabric` string, string, required

## Request body

- union
  - PostApiViewSemantic
    - `name` string, required: The name of the semantic search view. This field is immutable.
    - `links` PostApiViewLinkSemanticProps: The link properties. If specified, *properties* should be a JSON object containing the following attributes:
      - `[collection-name]` PostApiViewSemanticFields: The link properties. If specified, *properties* should be a JSON object containing the following attributes:
        - `fields` PostApiViewSemanticFieldDef: A list of link properties that are applied at each document level with each key specifying a document attribute
          - `[field-name]` object, required
            - `size` integer, required: The size of the vector.
            - `distanceType` 'L2' | 'IP' | 'COSINE', required: The measure of distance employed to assess the degree of similarity. Acceptable options include "L2" (Euclidean distance), "IP" (inner product), and "COSINE" (cosine similarity).
            - `indexConfig` object, required
              - …
            - `quantizationConfig` object
              - …
    - `type` string, required: The type of the search view. Must be equal to *semantic_search*.
  - PostApiViewIresearch
    - `name` string, required: The name of the search view. This field is immutable.
    - `primarySort` object[]: Specify default sorting order. This field is immutable.
      - `field` string: The name of the field.
      - `direction` string: The sorting direction.
    - `links` PostApiViewLinks: The set of collection names associated with the properties.
      - `[collection-name]` PostApiViewLinkProps: The link properties. If specified, *properties* should be a JSON object containing the following attributes:
        - `analyzers` string[]: The list of analyzers to be used for indexing of string values.
        - `fields` PostApiViewFields: A list of link properties that are applied at each document level with each key specifying a document attribute.
          - `[field-name]` object: This is a recursive structure for the specific attribute path, potentially containing any of the following attributes: *analyzers*, *includeAllFields*, *trackListPositions*, *storeValues*. Any attributes not specified are inherited from the parent.
        - `includeAllFields` boolean: The flag determines whether or not to index all fields on a particular level of depth.
        - `storeValues` string: How should the search view track the attribute values, this setting allows for additional value retrieval optimizations, one of: - *none*: Do not store values by the search view - *id*: Store only information about value presence, to allow use of the EXISTS() function.
        - `trackListPositions` boolean: The flag determines whether or not values in a lists should be treated separate.
    - `type` string, required: The type of the search view. Must be equal to *search*.

## Response `201`

Successfully created search view.

- ApiSearchPostViewHttpExamplesRc201
  - `globallyUniqueId` string: Gloable Unique identifier of the search view.
  - `id` string: Unique identifier of the search view.
  - `name` string: The name of the search view. This field is immutable.
  - `primarySort` object[]: Specify default sorting order. This field is immutable.
    - `field` string: The name of the field.
    - `direction` string: The sorting direction.
  - `links` PostApiViewLinks: The set of collection names associated with the properties.
    - `[collection-name]` PostApiViewLinkProps: The link properties. If specified, *properties* should be a JSON object containing the following attributes:
      - `analyzers` string[]: The list of analyzers to be used for indexing of string values.
      - `fields` PostApiViewFields: A list of link properties that are applied at each document level with each key specifying a document attribute.
        - `[field-name]` object: This is a recursive structure for the specific attribute path, potentially containing any of the following attributes: *analyzers*, *includeAllFields*, *trackListPositions*, *storeValues*. Any attributes not specified are inherited from the parent.
      - `includeAllFields` boolean: The flag determines whether or not to index all fields on a particular level of depth.
      - `storeValues` string: How should the search view track the attribute values, this setting allows for additional value retrieval optimizations, one of: - *none*: Do not store values by the search view - *id*: Store only information about value presence, to allow use of the EXISTS() function.
      - `trackListPositions` boolean: The flag determines whether or not values in a lists should be treated separate.
  - `type` string: The type of the search view. must be equal to *search*.

## Other responses

- `400`: Failed due to missing or malformed data. Verify that all parameters are complete.
- `403`: Failed to validate because you do not have access to the server.
- `404`: Failed to find specified collection.
- `409`: Successfully found existing search view with same name.

---

[API](https://skmtc.dev/macrometa/apis/macrometa-api-reference.md) - [All operations](https://skmtc.dev/macrometa/apis/macrometa-api-reference/llms.txt) - [OpenAPI document](https://skmtc.dev/macrometa/apis/macrometa-api-reference/revisions/2006b6d7f31d?raw)
