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

# Update a configuration

> Updates a QuerySuggestions configuration.

**Required ACL:** `editSettings`


## OpenAPI

````yaml specs/query-suggestions.yml put /1/configs/{indexName}
openapi: 3.1.0
info:
  title: Query Suggestions API
  summary: >-
    The Query Suggestions API lets you manage your Query Suggestions
    configurations
  description: >
    Query Suggestions add new indices to your Algolia application with popular
    search queries, external suggestions, or facet values.

    In your user interface, you can query the Query Suggestions indices like
    regular indices and add [suggested
    searches](https://www.algolia.com/doc/guides/building-search-ui/ui-and-ux-patterns/query-suggestions/js)
    to guide users and speed up their search.


    ## Base URLs


    Base URLs for the Query Suggestions API:


    - `https://query-suggestions.us.algolia.com`

    - `https://query-suggestions.eu.algolia.com`


    Use the URL that matches your [analytics
    region](https://dashboard.algolia.com/account/infrastructure/analytics).


    **All requests must use HTTPS.**


    ## Authentication


    Add these headers to authenticate requests:


    - `x-algolia-application-id`. Your Algolia application ID.

    - `x-algolia-api-key`. An API key with the necessary permissions to make the
    request.
      The required access control list (ACL) to make a request is listed in each endpoint's reference.

    You can find your application ID and API key in the [Algolia
    dashboard](https://dashboard.algolia.com/account/api-keys).


    ## Request format


    Request bodies must be JSON objects.


    ## Response status and errors


    Response bodies are JSON objects.

    Deleting a user token returns an empty response body with rate-limiting
    information as headers.


    Successful responses return `2xx` statuses. Client errors return `4xx`
    statuses. Server errors return `5xx` statuses.

    Error responses have a `message` property with more information.


    ## Version


    The current version of the Query Suggestions API is version 1, indicated by
    the `/1/` in each endpoint's URL.
  version: 1.0.0
servers:
  - url: https://query-suggestions.{region}.algolia.com
    description: >
      You can check the region for your application in the [Algolia
      dashboard](https://dashboard.algolia.com/account/infrastructure/analytics).

      If you connect to the wrong region, the API returns an error with the
      status `401` and the message: "The log processing region does not match".
    variables:
      region:
        description: The region where your Algolia application is hosted.
        enum:
          - us
          - eu
        default: us
security:
  - appId: []
    apiKey: []
tags:
  - name: configurations
    x-displayName: Configurations
    description: Manage Query Suggestions configurations.
  - name: logs
    x-displayName: Logs
    description: Get logs for a Query Suggestions index.
paths:
  /1/configs/{indexName}:
    put:
      tags:
        - configurations
      summary: Update a configuration
      description: Updates a QuerySuggestions configuration.
      operationId: updateConfig
      parameters:
        - $ref: '#/components/parameters/IndexName'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Configuration'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BaseResponse'
              examples:
                Created:
                  summary: Configuration created
                  value:
                    status: 200
                    message: >-
                      Configuration was updated, and a new indexing job has been
                      scheduled.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '500':
          $ref: '#/components/responses/InternalError-2'
      x-codeSamples:
        - lang: csharp
          label: C#
          source: |-
            // Initialize the client
            var client = new QuerySuggestionsClient(
              new QuerySuggestionsConfig(
                "ALGOLIA_APPLICATION_ID",
                "ALGOLIA_API_KEY",
                "ALGOLIA_APPLICATION_REGION"
              )
            );

            // Call the API
            var response = await client.UpdateConfigAsync(
              "<YOUR_INDEX_NAME>",
              new Configuration
              {
                SourceIndices = new List<SourceIndex>
                {
                  new SourceIndex
                  {
                    IndexName = "<YOUR_INDEX_NAME>",
                    Facets = new List<Facet> { new Facet { Attribute = "test" } },
                    Generate = new List<List<string>>
                    {
                      new List<string> { "facetA", "facetB" },
                      new List<string> { "facetC" },
                    },
                  },
                },
                Languages = new Languages(new List<string> { "french" }),
                Exclude = new List<string> { "test" },
              }
            );

            // print the response
            Console.WriteLine(response);
        - lang: go
          label: Go
          source: >-
            // Initialize the client with your application region, eg.
            suggestions.ALGOLIA_APPLICATION_REGION

            client, err := suggestions.NewClient("ALGOLIA_APPLICATION_ID",
            "ALGOLIA_API_KEY", suggestions.US)

            if err != nil {
              // The client can fail to initialize if you pass an invalid parameter.
              panic(err)
            }


            // Call the API

            response, err :=
            client.UpdateConfig(client.NewApiUpdateConfigRequest(
              "<YOUR_INDEX_NAME>",
              suggestions.NewEmptyConfiguration().SetSourceIndices(
                []suggestions.SourceIndex{*suggestions.NewEmptySourceIndex().SetIndexName("<YOUR_INDEX_NAME>").SetFacets(
                  []suggestions.Facet{*suggestions.NewEmptyFacet().SetAttribute("test")}).SetGenerate(
                  [][]string{
                    {"facetA", "facetB"},
                    {"facetC"},
                  })}).SetLanguages(suggestions.ArrayOfStringAsLanguages(
                []string{"french"})).SetExclude(
                []string{"test"})))
            if err != nil {
              // handle the eventual error
              panic(err)
            }



            // print the response

            print(response)
        - lang: java
          label: Java
          source: >-
            // Initialize the client

            QuerySuggestionsClient client = new
            QuerySuggestionsClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY",
            "ALGOLIA_APPLICATION_REGION");


            // Call the API

            BaseResponse response = client.updateConfig(
              "<YOUR_INDEX_NAME>",
              new Configuration()
                .setSourceIndices(
                  Arrays.asList(
                    new SourceIndex()
                      .setIndexName("<YOUR_INDEX_NAME>")
                      .setFacets(Arrays.asList(new Facet().setAttribute("test")))
                      .setGenerate(Arrays.asList(Arrays.asList("facetA", "facetB"), Arrays.asList("facetC")))
                  )
                )
                .setLanguages(Languages.of(Arrays.asList("french")))
                .setExclude(Arrays.asList("test"))
            );


            // print the response

            System.out.println(response);
        - lang: javascript
          label: JavaScript
          source: >-
            // Initialize the client

            // Replace 'us' with your Algolia Application Region

            const client = algoliasearch('ALGOLIA_APPLICATION_ID',
            'ALGOLIA_API_KEY').initQuerySuggestions({ region: 'us' });


            // Call the API

            const response = await client.updateConfig({
              indexName: 'theIndexName',
              configuration: {
                sourceIndices: [
                  { indexName: 'testIndex', facets: [{ attribute: 'test' }], generate: [['facetA', 'facetB'], ['facetC']] },
                ],
                languages: ['french'],
                exclude: ['test'],
              },
            });



            // print the response

            console.log(response);
        - lang: kotlin
          label: Kotlin
          source: |-
            // Initialize the client
            val client =
              QuerySuggestionsClient(
                appId = "ALGOLIA_APPLICATION_ID",
                apiKey = "ALGOLIA_API_KEY",
                region = "ALGOLIA_APPLICATION_REGION",
              )

            // Call the API
            var response =
              client.updateConfig(
                indexName = "<YOUR_INDEX_NAME>",
                configuration =
                  Configuration(
                    sourceIndices =
                      listOf(
                        SourceIndex(
                          indexName = "<YOUR_INDEX_NAME>",
                          facets = listOf(Facet(attribute = "test")),
                          generate = listOf(listOf("facetA", "facetB"), listOf("facetC")),
                        )
                      ),
                    languages = Languages.of(listOf("french")),
                    exclude = listOf("test"),
                  ),
              )


            // print the response
            println(response)
        - lang: php
          label: PHP
          source: >-
            // Initialize the client

            $client = QuerySuggestionsClient::create('ALGOLIA_APPLICATION_ID',
            'ALGOLIA_API_KEY', 'ALGOLIA_APPLICATION_REGION');


            // Call the API

            $response = $client->updateConfig(
                '<YOUR_INDEX_NAME>',
                ['sourceIndices' => [
                    ['indexName' => '<YOUR_INDEX_NAME>',
                        'facets' => [
                            ['attribute' => 'test',
                            ],
                        ],
                        'generate' => [
                            [
                                'facetA',

                                'facetB',
                            ],

                            [
                                'facetC',
                            ],
                        ],
                    ],
                ],
                    'languages' => [
                        'french',
                    ],
                    'exclude' => [
                        'test',
                    ],
                ],
            );



            // print the response

            var_dump($response);
        - lang: python
          label: Python
          source: >-
            # Initialize the client

            # In an asynchronous context, you can use QuerySuggestionsClient
            instead, which exposes the exact same methods.

            client = QuerySuggestionsClientSync(
                "ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY", "ALGOLIA_APPLICATION_REGION"
            )


            # Call the API

            response = client.update_config(
                index_name="<YOUR_INDEX_NAME>",
                configuration={
                    "sourceIndices": [
                        {
                            "indexName": "<YOUR_INDEX_NAME>",
                            "facets": [
                                {
                                    "attribute": "test",
                                },
                            ],
                            "generate": [
                                [
                                    "facetA",
                                    "facetB",
                                ],
                                [
                                    "facetC",
                                ],
                            ],
                        },
                    ],
                    "languages": [
                        "french",
                    ],
                    "exclude": [
                        "test",
                    ],
                },
            )



            # print the response

            print(response)
        - lang: ruby
          label: Ruby
          source: |-
            # Initialize the client
            client = Algolia::QuerySuggestionsClient.create(
              "ALGOLIA_APPLICATION_ID",
              "ALGOLIA_API_KEY",
              "ALGOLIA_APPLICATION_REGION"
            )

            # Call the API
            response = client.update_config(
              "<YOUR_INDEX_NAME>",
              Algolia::QuerySuggestions::Configuration.new(
                source_indices: [
                  Algolia::QuerySuggestions::SourceIndex.new(
                    index_name: "<YOUR_INDEX_NAME>",
                    facets: [Algolia::QuerySuggestions::Facet.new(attribute: "test")],
                    generate: [["facetA", "facetB"], ["facetC"]]
                  )
                ],
                languages: ["french"],
                exclude: ["test"]
              )
            )


            # print the response
            puts(response)
        - lang: scala
          label: Scala
          source: |-
            // Initialize the client
            val client = QuerySuggestionsClient(
              appId = "ALGOLIA_APPLICATION_ID",
              apiKey = "ALGOLIA_API_KEY",
              region = "ALGOLIA_APPLICATION_REGION"
            )

            // Call the API
            val response = Await.result(
              client.updateConfig(
                indexName = "<YOUR_INDEX_NAME>",
                configuration = Configuration(
                  sourceIndices = Seq(
                    SourceIndex(
                      indexName = "<YOUR_INDEX_NAME>",
                      facets = Some(
                        Seq(
                          Facet(
                            attribute = Some("test")
                          )
                        )
                      ),
                      generate = Some(Seq(Seq("facetA", "facetB"), Seq("facetC")))
                    )
                  ),
                  languages = Some(Languages(Seq("french"))),
                  exclude = Some(Seq("test"))
                )
              ),
              Duration(100, "sec")
            )

            // print the response
            println(response)
        - lang: swift
          label: Swift
          source: >-
            // Initialize the client

            let client = try QuerySuggestionsClient(appID:
            "ALGOLIA_APPLICATION_ID", apiKey: "ALGOLIA_API_KEY", region: .us)


            // Call the API

            let response = try await client.updateConfig(
                indexName: "<YOUR_INDEX_NAME>",
                configuration: QuerySuggestionsConfiguration(
                    sourceIndices: [SourceIndex(
                        indexName: "<YOUR_INDEX_NAME>",
                        facets: [Facet(attribute: "test")],
                        generate: [["facetA", "facetB"], ["facetC"]]
                    )],
                    languages: QuerySuggestionsLanguages.arrayOfString(["french"]),
                    exclude: ["test"]
                )
            )


            // print the response

            print(response)
        - lang: cURL
          label: curl
          source: |-
            curl --request PUT \
              --url https://query-suggestions.us.algolia.com/1/configs/ALGOLIA_INDEX_NAME \
              --header 'accept: application/json' \
              --header 'content-type: application/json' \
              --header 'x-algolia-api-key: ALGOLIA_API_KEY' \
              --header 'x-algolia-application-id: ALGOLIA_APPLICATION_ID' \
              --data '
            {
              "sourceIndices": [
                {
                  "indexName": "products",
                  "replicas": false,
                  "analyticsTags": [
                    "lorem"
                  ],
                  "facets": [
                    {
                      "attribute": "category",
                      "amount": 3
                    },
                    {
                      "attribute": "brand",
                      "amount": 2
                    }
                  ],
                  "minHits": 5,
                  "minLetters": 4,
                  "generate": [
                    [
                      "color",
                      "brand"
                    ]
                  ],
                  "external": [
                    "lorem"
                  ]
                }
              ],
              "languages": [
                "lorem"
              ],
              "exclude": [
                "lorem"
              ],
              "enablePersonalization": false,
              "allowSpecialCharacters": false
            }
            '
components:
  parameters:
    IndexName:
      name: indexName
      in: path
      required: true
      description: Query Suggestions index name.
      schema:
        $ref: '#/components/schemas/IndexName'
  schemas:
    Configuration:
      type: object
      description: Query Suggestions configuration.
      required:
        - sourceIndices
      properties:
        sourceIndices:
          type: array
          description: >-
            Algolia indices from which to get the popular searches for query
            suggestions.
          minItems: 1
          items:
            $ref: '#/components/schemas/SourceIndex'
        allowSpecialCharacters:
          type: boolean
          default: false
          description: Whether to include suggestions with special characters.
        enablePersonalization:
          type: boolean
          default: false
          description: Whether to turn on personalized query suggestions.
        exclude:
          $ref: '#/components/schemas/Exclude'
        languages:
          $ref: '#/components/schemas/Languages'
    BaseResponse:
      type: object
      properties:
        message:
          type: string
          description: Details about the response, such as error messages.
        status:
          type: integer
          description: HTTP status code.
    IndexName:
      title: indexName
      type: string
      description: Name of the Query Suggestions index (case-sensitive).
      example: ALGOLIA_INDEX_NAME
    SourceIndex:
      type: object
      description: Configuration of an Algolia index for Query Suggestions.
      required:
        - indexName
      properties:
        indexName:
          type: string
          description: >-
            Name of the Algolia index (case-sensitive) to use as source for
            query suggestions.
          example: products
        analyticsTags:
          $ref: '#/components/schemas/AnalyticsTags'
        external:
          $ref: '#/components/schemas/External'
        facets:
          $ref: '#/components/schemas/Facets'
        generate:
          $ref: '#/components/schemas/Generate'
        minHits:
          type: integer
          minimum: 0
          default: 5
          description: >
            Minimum number of hits required to be included as a suggestion.


            A search query must at least generate `minHits` search results to be
            included in the Query Suggestions index.
        minLetters:
          type: integer
          minimum: 0
          default: 4
          description: >
            Minimum letters required to be included as a suggestion.


            A search query must be at least `minLetters` long to be included in
            the Query Suggestions index.
        replicas:
          type: boolean
          default: false
          description: >
            If true, Query Suggestions uses all replica indices to find popular
            searches.

            If false, only the primary index is used.
          example: false
    Exclude:
      title: exclude
      description: Words or regular expressions to exclude from the suggestions.
      default: null
      oneOf:
        - type: array
          items:
            type: string
        - type: 'null'
    Languages:
      title: languages
      description: |
        Languages for deduplicating singular and plural suggestions.
        If specified, only the more popular form is included.
      default: false
      oneOf:
        - type: array
          description: Languages for which to deduplicate singular and plural forms.
          items:
            type: string
            description: Two-letter country code.
        - type: boolean
          description: If true, deduplication is enabled for all languages.
    AnalyticsTags:
      title: analyticsTags
      description: >
        Analytics tags for filtering the popular searches.

        For more information, see [Segment your analytics
        data](https://www.algolia.com/doc/guides/search-analytics/guides/segments).
      default: null
      oneOf:
        - type: array
          items:
            type: string
        - type: 'null'
    External:
      description: >
        Algolia indices with popular searches to use as query suggestions.


        Records of these indices must have these attributes:


        - `query`: search query which will be added as a suggestion

        - `count`: measure of popularity of that search query


        For example, you can export popular searches from an external analytics
        provider, such as Google Analytics or Adobe Analytics,

        and feed this data into an Algolia index.

        You can use this index to generate query suggestions until your Algolia
        Analytics has collected enough data.
      default: null
      oneOf:
        - type: array
          items:
            type: string
        - type: 'null'
    Facets:
      title: facets
      description: >
        Facets to use as top categories with your suggestions.


        If provided, Query Suggestions adds the top facet values to each
        suggestion.
      default: null
      oneOf:
        - type: array
          items:
            $ref: '#/components/schemas/Facet'
        - type: 'null'
      example:
        - attribute: category
          amount: 3
        - attribute: brand
          amount: 2
    Generate:
      title: generate
      description: >
        Facets used for generating query suggestions from facet values.


        For example, if you set `generate: ["color", "brand"]`, combinations
        from the facet values are added as query suggestions,

        such as "blue adidas", "red adidas", "blue nike", "red nike", etc.


        You can include nested lists.
      default: null
      oneOf:
        - type: array
          items:
            type: array
            items:
              type: string
        - type: 'null'
      example:
        - - color
          - brand
    Facet:
      type: object
      description: Facet to use as category.
      properties:
        amount:
          type: integer
          description: Number of suggestions.
        attribute:
          type: string
          description: Facet name.
  responses:
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/BaseResponse'
          examples:
            Unauthorized:
              summary: Wrong region
              description: >
                Make sure to make your request to the server corresponding to
                your region.


                You can check the region for your application in the [Algolia
                dashboard](https://dashboard.algolia.com/account/infrastructure/analytics).
              value:
                status: 401
                message: The log processing region does not match.
            InvalidCredentials:
              summary: Invalid credentials
              description: Your application ID or API key is wrong.
              value:
                status: 401
                message: Invalid credentials
            MissingACL:
              summary: Key is missing ACL
              description: Your API key is missing the required ACL for this operation.
              value:
                status: 401
                message: The provided API key is missing the \"editSettings\" ACL.
    InternalError-2:
      description: Internal Server Error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/BaseResponse'
          examples:
            Error:
              description: >-
                This error can happen if you use a non-existing `indexName` as a
                path parameter when trying to update or delete a Query
                Suggestions configuration.
              value:
                status: 500
                message: Internal Server Error
  securitySchemes:
    appId:
      type: apiKey
      in: header
      name: x-algolia-application-id
      description: Your Algolia application ID.
    apiKey:
      type: apiKey
      in: header
      name: x-algolia-api-key
      description: >
        Your Algolia API key with the necessary permissions to make the request.

        Permissions are controlled through access control lists (ACL) and access
        restrictions.

        The required ACL to make a request is listed in each endpoint's
        reference.

````