> ## Documentation Index
> Fetch the complete documentation index at: https://docs.doofinder.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Suggestions

> Search through indexed suggestions of a search engine.



## OpenAPI

````yaml /openapi/search-v6.yaml get /6/{hashid}/_suggest
openapi: 3.0.0
info:
  title: Search API
  contact:
    name: Doofinder Support
    url: https://docs.doofinder.com/
  version: '6.0'
  description: >
    # Introduction

    Search API allows you to perform the search requests you can do on your
    search

    engines using the doofinder layer, directly from your code.

    # Basics

    ## Endpoint

    All requests should be done with `https` protocol in our api location.

    `https://{search_zone}-search.doofinder.com`

    where `{search_zone}` depends on your location, is the geographic zone your
    search engine is located at.

    i.e.: eu1. Also, indicates which host to use in your API calls.

    ## Authentication

    The authentication method for search API requires an api key that could be
    obtained in our

    [management control panel](https://admin.doofinder.com).

    You can generate it in your user account -> Api Keys.

    Example of the generated API Key:

    `eu1-ab46030xza33960aac71a10248489b6c26172f07`

    ### API Token

    You could authenticate with the previous API key in header as a Token. The
    correct way to authenticate is

    to send a HTTP Header with the name `Authorization` and the value `Token
    <API Key>`

    For example, for the key shown above:

    `Authorization: Token eu1-ab46030xza33960aac71a10248489b6c26172f07`

    ## Conventions

    Along most of the code samples you will find placeholders for some common
    variable values. They are:

    - `{hashid}`: The search engine's unique id. i.e.:
    d8fdeab7fce96a19d3fc7b0ca7a1e98b

    - `{token}`: Your personal authentication token obtained in the control
    panel.

    - `{index}`: The index of the data you're searching at. i.e.: product

    - `{id}`: Unique identification of a resource. i.e.: 1234 or HVIUYC
  termsOfService: https://www.doofinder.com/es/terms-and-conditions
  x-logo:
    url: https://admin.doofinder.com/images/logo.svg
    backgroundColor: '#33268C'
    altText: Doofinder Search Engine
servers:
  - url: https://{search_zone}-search.doofinder.com
    variables:
      search_zone:
        enum:
          - eu1
          - us1
          - ap1
        default: eu1
  - url: /
security:
  - api_token: []
tags:
  - name: Search
    description: Search operations.
  - name: Session & Events
    description: Stats operations.
paths:
  /6/{hashid}/_suggest:
    get:
      tags:
        - Search
      summary: Suggestions
      description: Search through indexed suggestions of a search engine.
      operationId: suggestion_query
      parameters:
        - $ref: '#/components/parameters/hashid'
        - $ref: '#/components/parameters/indices'
        - $ref: '#/components/parameters/query'
        - $ref: '#/components/parameters/session_id_query'
        - $ref: '#/components/parameters/user_id_query'
        - $ref: '#/components/parameters/stats'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuggestionsResponse'
        '400':
          description: >-
            Bad Request — query exceeds 200 characters or 10 words, or
            session_id/user_id too long.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_query:
                  summary: Query too long or too many words
                  value:
                    error: '"query" has an invalid value'
                invalid_session_id:
                  summary: session_id too long
                  value:
                    error: session_id should have 32 characters or less
        '403':
          description: >-
            Forbidden — missing or invalid API token, client IP is blocked, or
            CORS `Origin` not allowed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                forbidden:
                  summary: Missing or invalid API token
                  value:
                    error: forbidden
                banned_ip:
                  summary: Client IP is blocked
                  value:
                    error: banned ip
        '404':
          description: >-
            Not Found — search engine mapping not found, or the requested index
            does not exist.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                mapping_not_found:
                  summary: Mapping not found
                  value:
                    error: Mapping not found
                index_not_found:
                  summary: Requested index does not exist
                  value:
                    error: Index product not found.
        '429':
          description: >-
            Too Many Requests — suggestions are not enabled for this search
            engine.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                summary: Suggestions not enabled
                value:
                  error: Suggestions not available
components:
  parameters:
    hashid:
      name: hashid
      in: path
      description: Unique id of a search engine.
      required: true
      schema:
        type: string
    indices:
      name: indices
      in: query
      description: >
        Your search engine is composed by one or many Indices. With the
        `indices` parameter you can specify to search

        within one specific Index. If this parameter is not provided, the search
        will work with all Indices.


        For instance, if you want to search within the "product" Index you
        should use the following query:


        `indices[]=product`


        In case you want to search within multiple Indices, the query will be:


        `indices[]=product&indices[]=page`


        The order of the values do not affect the results order.


        Note that `[` and `]` characters should be escaped (`%5B` and `%5D`) in
        all cases.
      schema:
        type: array
        items:
          type: string
      example:
        indices[]: product
    query:
      name: query
      in: query
      description: >-
        The search term. It must be escaped and it cannot be longer than 200
        characters or 10 words.
      schema:
        type: string
    session_id_query:
      name: session_id
      in: query
      description: The current session ID, must be unique for each user.
      schema:
        $ref: '#/components/schemas/session_id'
    user_id_query:
      name: user_id
      in: query
      description: Identifies the user, must be unique for each user.
      schema:
        $ref: '#/components/schemas/user_id'
    stats:
      name: stats
      in: query
      description: 'Enable/Disable this search in stats reports. Default: true'
      schema:
        type: boolean
  schemas:
    SuggestionsResponse:
      title: Suggestions Response
      description: Response returned on suggestions search.
      type: array
      items:
        type: string
      example:
        - Sugg
        - Suggest
        - Suggestion
    ErrorResponse:
      type: object
      description: Standard error response returned on all non-200 outcomes.
      properties:
        error:
          type: string
          description: Human-readable error message.
      required:
        - error
    session_id:
      type: string
      description: Identifier of search session
      maxLength: 32
    user_id:
      type: string
      description: Identifier of user
      maxLength: 36
  securitySchemes:
    api_token:
      type: apiKey
      description: |
        Doofinder API key. Pass it as:
        Authorization: Token <api_key>
      name: Authorization
      in: header

````