# Discovery Engine API . projects . locations . collections . engines . completionConfig

## Instance Methods

Close httplib2 connections.

Completes the user input with advanced keyword suggestions.

Removes the search history suggestion in an engine for a user. This will remove the suggestion from being returned in the AdvancedCompleteQueryResponse.recent_search_suggestions for this user. If the user searches the same suggestion again, the new history will override and suggest this suggestion again.

### Method Details

`close()`

    Close httplib2 connections.

`completeQuery(completionConfig, body=None, x__xgafv=None)`

    Completes the user input with advanced keyword suggestions.

    Args:
      completionConfig: string, Required. The completion_config of the parent dataStore or engine resource name for which the completion is performed, such as `projects/*/locations/global/collections/default_collection/dataStores/*/completionConfig` `projects/*/locations/global/collections/default_collection/engines/*/completionConfig`. (required)
      body: object, The request body.
        The object takes the form of:

    { # Request message for CompletionService.AdvancedCompleteQuery method. .
      "boostSpec": { # Specification to boost suggestions based on the condtion of the suggestion. # Optional. Specification to boost suggestions matching the condition.
        "conditionBoostSpecs": [ # Condition boost specifications. If a suggestion matches multiple conditions in the specifications, boost values from these specifications are all applied and combined in a non-linear way. Maximum number of specifications is 20. Note: Currently only support language condition boost.
          { # Boost applies to suggestions which match a condition.
            "boost": 3.14, # Strength of the boost, which should be in [-1, 1]. Negative boost means demotion. Default is 0.0. Setting to 1.0 gives the suggestions a big promotion. However, it does not necessarily mean that the top result will be a boosted suggestion. Setting to -1.0 gives the suggestions a big demotion. However, other suggestions that are relevant might still be shown. Setting to 0.0 means no boost applied. The boosting condition is ignored.
            "condition": "A String", # An expression which specifies a boost condition. The syntax is the same as [filter expression syntax](https://cloud.google.com/generative-ai-app-builder/docs/filter-search-metadata#filter-expression-syntax). Currently, the only supported condition is a list of BCP-47 lang codes. Example: * To boost suggestions in languages `en` or `fr`: `(lang_code: ANY("en", "fr"))`
          },
        ],
      },
      "experimentIds": [ # Optional. Experiment ids for this request.
        "A String",
      ],
      "includeTailSuggestions": True or False, # Indicates if tail suggestions should be returned if there are no suggestions that match the full query. Even if set to true, if there are suggestions that match the full query, those are returned and no tail suggestions are returned.
      "query": "A String", # Required. The typeahead input used to fetch suggestions. Maximum length is 128 characters. The query can not be empty for most of the suggestion types. If it is empty, an `INVALID_ARGUMENT` error is returned. The exception is when the suggestion_types contains only the type `RECENT_SEARCH`, the query can be an empty string. The is called "zero prefix" feature, which returns user's recently searched queries given the empty query.
      "queryModel": "A String", # Specifies the autocomplete query model, which only applies to the QUERY SuggestionType. This overrides any model specified in the Configuration > Autocomplete section of the Cloud console. Currently supported values: * `document` - Using suggestions generated from user-imported documents. * `search-history` - Using suggestions generated from the past history of SearchService.Search API calls. Do not use it when there is no traffic for Search API. * `user-event` - Using suggestions generated from user-imported search events. * `document-completable` - Using suggestions taken directly from user-imported document fields marked as completable. Default values: * `document` is the default model for regular dataStores. * `search-history` is the default model for site search dataStores.
      "suggestionTypeSpecs": [ # Optional. Specification of each suggestion type.
        { # Specification of each suggestion type.
          "maxSuggestions": 42, # Optional. Maximum number of suggestions to return for each suggestion type.
          "suggestionType": "A String", # Optional. Suggestion type.
        },
      ],
      "suggestionTypes": [ # Optional. Suggestion types to return. If empty or unspecified, query suggestions are returned. Only one suggestion type is supported at the moment.
        "A String",
      ],
      "userInfo": { # Information of an end user. # Optional. Information about the end user. This should be the same identifier information as UserEvent.user_info and SearchRequest.user_info.
        "timeZone": "A String", # Optional. IANA time zone, e.g. Europe/Budapest.
        "userAgent": "A String", # User agent as included in the HTTP header. The field must be a UTF-8 encoded string with a length limit of 1,000 characters. Otherwise, an `INVALID_ARGUMENT` error is returned. This should not be set when using the client side event reporting with GTM or JavaScript tag in UserEventService.CollectUserEvent or if UserEvent.direct_user_request is set.
        "userId": "A String", # Highly recommended for logged-in users. Unique identifier for logged-in user, such as a user name. Don't set for anonymous users. Always use a hashed value for this ID. Don't set the field to the same fixed ID for different users. This mixes the event history of those users together, which results in degraded model quality. The field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an `INVALID_ARGUMENT` error is returned.
      },
      "userPseudoId": "A String", # A unique identifier for tracking visitors. For example, this could be implemented with an HTTP cookie, which should be able to uniquely identify a visitor on a single device. This unique identifier should not change if the visitor logs in or out of the website. This field should NOT have a fixed value such as `unknown_visitor`. This should be the same identifier as UserEvent.user_pseudo_id and SearchRequest.user_pseudo_id. The field must be a UTF-8 encoded string with a length limit of 128
    }

      x__xgafv: string, V1 error format.
        Allowed values
          1 - v1 error format
          2 - v2 error format

    Returns:
      An object of the form:

        { # Response message for CompletionService.AdvancedCompleteQuery method.
      "contentSuggestions": [ # Results of the matched content suggestions. The result list is ordered and the first result is the top suggestion.
        { # Suggestions as content.
          "contentType": "A String", # The type of the content suggestion.
          "dataStore": "A String", # The name of the dataStore that this suggestion belongs to.
          "destinationUri": "A String", # The destination uri of the content suggestion.
          "document": { # Document captures all raw metadata information of items to be recommended or searched. # The document data snippet in the suggestion. Only a subset of fields will be populated.
            "aclInfo": { # ACL Information of the Document. # Access control information for the document.
              "readers": [ # Readers of the document.
                { # AclRestriction to model complex inheritance restrictions. Example: Modeling a "Both Permit" inheritance, where to access a child document, user needs to have access to parent document. Document Hierarchy - Space_S --> Page_P. Readers: Space_S: group_1, user_1 Page_P: group_2, group_3, user_2 Space_S ACL Restriction - { "acl_info": { "readers": [ { "principals": [ { "group_id": "group_1" }, { "user_id": "user_1" } ] } ] } } Page_P ACL Restriction. { "acl_info": { "readers": [ { "principals": [ { "group_id": "group_2" }, { "group_id": "group_3" }, { "user_id": "user_2" } ], }, { "principals": [ { "group_id": "group_1" }, { "user_id": "user_1" } ], } ] } }
                  "idpWide": True or False, # All users within the Identity Provider.
                  "principals": [ # List of principals.
                    { # Principal identifier of a user or a group.
                      "externalEntityId": "A String", # For 3P application identities which are not present in the customer identity provider.
                      "groupId": "A String", # Group identifier. For Google Workspace user account, group_id should be the google workspace group email. For non-google identity provider user account, group_id is the mapped group identifier configured during the workforcepool config.
                      "userId": "A String", # User identifier. For Google Workspace user account, user_id should be the google workspace user email. For non-google identity provider user account, user_id is the mapped user identifier configured during the workforcepool config.
                    },
                  ],
                },
              ],
            },
            "content": { # Unstructured data linked to this document. # The unstructured data linked to this document. Content can only be set and must be set if this document is under a `CONTENT_REQUIRED` data store.
              "mimeType": "A String", # The MIME type of the content. Supported types: * `application/pdf` (PDF, only native PDFs are supported for now) * `text/html` (HTML) * `text/plain` (TXT) * `application/xml` or `text/xml` (XML) * `application/json` (JSON) * `application/vnd.openxmlformats-officedocument.wordprocessingml.document` (DOCX) * `application/vnd.openxmlformats-officedocument.presentationml.presentation` (PPTX) * `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet` (XLSX) * `application/vnd.ms-excel.sheet.macroenabled.12` (XLSM) The following types are supported only if layout parser is enabled in the data store: * `image/bmp` (BMP) * `image/gif` (GIF) * `image/jpeg` (JPEG) * `image/png` (PNG) * `image/tiff` (TIFF) See https://www.iana.org/assignments/media-types/media-types.xhtml.
              "rawBytes": "A String", # The content represented as a stream of bytes. The maximum length is 1,000,000 bytes (1 MB / ~0.95 MiB). Note: As with all `bytes` fields, this field is represented as pure binary in Protocol Buffers and base64-encoded string in JSON. For example, `abc123!?$*&()'-=@~` should be represented as `YWJjMTIzIT8kKiYoKSctPUB+` in JSON. See https://developers.google.com/protocol-buffers/docs/proto3#json.
              "uri": "A String", # The URI of the content. Only Cloud Storage URIs (e.g. `gs://bucket-name/path/to/file`) are supported. The maximum file size is 2.5 MB for text-based formats, 200 MB for other formats.
            },
            "derivedStructData": { # Output only. This field is OUTPUT_ONLY. It contains derived data that are not in the original input document.
              "a_key": "", # Properties of the object.
            },
            "id": "A String", # Immutable. The identifier of the document. Id should conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with a length limit of 128 characters.
            "indexStatus": { # Index status of the document. # Output only. The index status of the document. * If document is indexed successfully, the index_time field is populated. * Otherwise, if document is not indexed due to errors, the error_samples field is populated. * Otherwise, if document's index is in progress, the pending_message field is populated.
              "errorSamples": [ # A sample of errors encountered while indexing the document. If this field is populated, the document is not indexed due to errors.
                { # The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
                  "code": 42, # The status code, which should be an enum value of google.rpc.Code.
                  "details": [ # A list of messages that carry the error details. There is a common set of message types for APIs to use.
                    {
                      "a_key": "", # Properties of the object. Contains field @type with type URL.
                    },
                  ],
                  "message": "A String", # A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
                },
              ],
              "indexTime": "A String", # The time when the document was indexed. If this field is populated, it means the document has been indexed.
              "pendingMessage": "A String", # Immutable. The message indicates the document index is in progress. If this field is populated, the document index is pending.
            },
            "indexTime": "A String", # Output only. The last time the document was indexed. If this field is set, the document could be returned in search results. This field is OUTPUT_ONLY. If this field is not populated, it means the document has never been indexed.
            "jsonData": "A String", # The JSON string representation of the document. It should conform to the registered Schema or an `INVALID_ARGUMENT` error is thrown.
            "name": "A String", # Immutable. The full resource name of the document. Format: `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document_id}`. This field must be a UTF-8 encoded string with a length limit of 1024 characters.
            "parentDocumentId": "A String", # The identifier of the parent document. Currently supports at most two level document hierarchy. Id should conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with a length limit of 63 characters.
            "schemaId": "A String", # The identifier of the schema located in the same data store.
            "structData": { # The structured JSON data for the document. It should conform to the registered Schema or an `INVALID_ARGUMENT` error is thrown.
              "a_key": "", # Properties of the object.
            },
          },
          "iconUri": "A String", # The icon uri of the content suggestion.
          "score": 3.14, # The score of each suggestion. The score is in the range of [0, 1].
          "suggestion": "A String", # The suggestion for the query.
        },
      ],
      "peopleSuggestions": [ # Results of the matched people suggestions. The result list is ordered and the first result is the top suggestion.
        { # Suggestions as people.
          "dataStore": "A String", # The name of the dataStore that this suggestion belongs to.
          "destinationUri": "A String", # The destination uri of the person suggestion.
          "displayPhotoUri": "A String", # The photo uri of the person suggestion.
          "document": { # Document captures all raw metadata information of items to be recommended or searched. # The document data snippet in the suggestion. Only a subset of fields is populated.
            "aclInfo": { # ACL Information of the Document. # Access control information for the document.
              "readers": [ # Readers of the document.
                { # AclRestriction to model complex inheritance restrictions. Example: Modeling a "Both Permit" inheritance, where to access a child document, user needs to have access to parent document. Document Hierarchy - Space_S --> Page_P. Readers: Space_S: group_1, user_1 Page_P: group_2, group_3, user_2 Space_S ACL Restriction - { "acl_info": { "readers": [ { "principals": [ { "group_id": "group_1" }, { "user_id": "user_1" } ] } ] } } Page_P ACL Restriction. { "acl_info": { "readers": [ { "principals": [ { "group_id": "group_2" }, { "group_id": "group_3" }, { "user_id": "user_2" } ], }, { "principals": [ { "group_id": "group_1" }, { "user_id": "user_1" } ], } ] } }
                  "idpWide": True or False, # All users within the Identity Provider.
                  "principals": [ # List of principals.
                    { # Principal identifier of a user or a group.
                      "externalEntityId": "A String", # For 3P application identities which are not present in the customer identity provider.
                      "groupId": "A String", # Group identifier. For Google Workspace user account, group_id should be the google workspace group email. For non-google identity provider user account, group_id is the mapped group identifier configured during the workforcepool config.
                      "userId": "A String", # User identifier. For Google Workspace user account, user_id should be the google workspace user email. For non-google identity provider user account, user_id is the mapped user identifier configured during the workforcepool config.
                    },
                  ],
                },
              ],
            },
            "content": { # Unstructured data linked to this document. # The unstructured data linked to this document. Content can only be set and must be set if this document is under a `CONTENT_REQUIRED` data store.
              "mimeType": "A String", # The MIME type of the content. Supported types: * `application/pdf` (PDF, only native PDFs are supported for now) * `text/html` (HTML) * `text/plain` (TXT) * `application/xml` or `text/xml` (XML) * `application/json` (JSON) * `application/vnd.openxmlformats-officedocument.wordprocessingml.document` (DOCX) * `application/vnd.openxmlformats-officedocument.presentationml.presentation` (PPTX) * `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet` (XLSX) * `application/vnd.ms-excel.sheet.macroenabled.12` (XLSM) The following types are supported only if layout parser is enabled in the data store: * `image/bmp` (BMP) * `image/gif` (GIF) * `image/jpeg` (JPEG) * `image/png` (PNG) * `image/tiff` (TIFF) See https://www.iana.org/assignments/media-types/media-types.xhtml.
              "rawBytes": "A String", # The content represented as a stream of bytes. The maximum length is 1,000,000 bytes (1 MB / ~0.95 MiB). Note: As with all `bytes` fields, this field is represented as pure binary in Protocol Buffers and base64-encoded string in JSON. For example, `abc123!?$*&()'-=@~` should be represented as `YWJjMTIzIT8kKiYoKSctPUB+` in JSON. See https://developers.google.com/protocol-buffers/docs/proto3#json.
              "uri": "A String", # The URI of the content. Only Cloud Storage URIs (e.g. `gs://bucket-name/path/to/file`) are supported. The maximum file size is 2.5 MB for text-based formats, 200 MB for other formats.
            },
            "derivedStructData": { # Output only. This field is OUTPUT_ONLY. It contains derived data that are not in the original input document.
              "a_key": "", # Properties of the object.
            },
            "id": "A String", # Immutable. The identifier of the document. Id should conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with a length limit of 128 characters.
            "indexStatus": { # Index status of the document. # Output only. The index status of the document. * If document is indexed successfully, the index_time field is populated. * Otherwise, if document is not indexed due to errors, the error_samples field is populated. * Otherwise, if document's index is in progress, the pending_message field is populated.
              "errorSamples": [ # A sample of errors encountered while indexing the document. If this field is populated, the document is not indexed due to errors.
                { # The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
                  "code": 42, # The status code, which should be an enum value of google.rpc.Code.
                  "details": [ # A list of messages that carry the error details. There is a common set of message types for APIs to use.
                    {
                      "a_key": "", # Properties of the object. Contains field @type with type URL.
                    },
                  ],
                  "message": "A String", # A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
                },
              ],
              "indexTime": "A String", # The time when the document was indexed. If this field is populated, it means the document has been indexed.
              "pendingMessage": "A String", # Immutable. The message indicates the document index is in progress. If this field is populated, the document index is pending.
            },
            "indexTime": "A String", # Output only. The last time the document was indexed. If this field is set, the document could be returned in search results. This field is OUTPUT_ONLY. If this field is not populated, it means the document has never been indexed.
            "jsonData": "A String", # The JSON string representation of the document. It should conform to the registered Schema or an `INVALID_ARGUMENT` error is thrown.
            "name": "A String", # Immutable. The full resource name of the document. Format: `projects/{project}/locations/{location}/collections/{collection}/dataStores/{data_store}/branches/{branch}/documents/{document_id}`. This field must be a UTF-8 encoded string with a length limit of 1024 characters.
            "parentDocumentId": "A String", # The identifier of the parent document. Currently supports at most two level document hierarchy. Id should conform to [RFC-1034](https://tools.ietf.org/html/rfc1034) standard with a length limit of 63 characters.
            "schemaId": "A String", # The identifier of the schema located in the same data store.
            "structData": { # The structured JSON data for the document. It should conform to the registered Schema or an `INVALID_ARGUMENT` error is thrown.
              "a_key": "", # Properties of the object.
            },
          },
          "personType": "A String", # The type of the person.
          "score": 3.14, # The score of each suggestion. The score is in the range of [0, 1].
          "suggestion": "A String", # The suggestion for the query.
        },
      ],
      "querySuggestions": [ # Results of the matched query suggestions. The result list is ordered and the first result is a top suggestion.
        { # Suggestions as search queries.
          "completableFieldPaths": [ # The unique document field paths that serve as the source of this suggestion if it was generated from completable fields. This field is only populated for the document-completable model.
            "A String",
          ],
          "dataStore": [ # The name of the dataStore that this suggestion belongs to.
            "A String",
          ],
          "score": 3.14, # The score of each suggestion. The score is in the range of [0, 1].
          "suggestion": "A String", # The suggestion for the query.
        },
      ],
      "recentSearchSuggestions": [ # Results of the matched "recent search" suggestions. The result list is ordered and the first result is the top suggestion.
        { # Suggestions from recent search history.
          "recentSearchTime": "A String", # The time when this recent rearch happened.
          "score": 3.14, # The score of each suggestion. The score is in the range of [0, 1].
          "suggestion": "A String", # The suggestion for the query.
        },
      ],
      "tailMatchTriggered": True or False, # True if the returned suggestions are all tail suggestions. For tail matching to be triggered, include_tail_suggestions in the request must be true and there must be no suggestions that match the full query.
    }

`removeSuggestion(completionConfig, body=None, x__xgafv=None)`

    Removes the search history suggestion in an engine for a user. This will remove the suggestion from being returned in the AdvancedCompleteQueryResponse.recent_search_suggestions for this user. If the user searches the same suggestion again, the new history will override and suggest this suggestion again.

    Args:
      completionConfig: string, Required. The completion_config of the parent engine resource name for which the search history suggestion is to be removed, such as `projects/*/locations/global/collections/default_collection/engines/*/completionConfig`. (required)
      body: object, The request body.
        The object takes the form of:

    { # Request message for CompletionService.RemoveSuggestion method.
      "removeAllSearchHistorySuggestions": True or False, # Remove all search history suggestions for the user.
      "removeTime": "A String", # Required. Time at which the suggestion was removed. If not set, the current time will be used.
      "searchHistorySuggestion": "A String", # The search history suggestion to be removed.
      "userInfo": { # Information of an end user. # Optional. Information about the end user. This should be the same identifier information as UserEvent.user_info and SearchRequest.user_info.
        "timeZone": "A String", # Optional. IANA time zone, e.g. Europe/Budapest.
        "userAgent": "A String", # User agent as included in the HTTP header. The field must be a UTF-8 encoded string with a length limit of 1,000 characters. Otherwise, an `INVALID_ARGUMENT` error is returned. This should not be set when using the client side event reporting with GTM or JavaScript tag in UserEventService.CollectUserEvent or if UserEvent.direct_user_request is set.
        "userId": "A String", # Highly recommended for logged-in users. Unique identifier for logged-in user, such as a user name. Don't set for anonymous users. Always use a hashed value for this ID. Don't set the field to the same fixed ID for different users. This mixes the event history of those users together, which results in degraded model quality. The field must be a UTF-8 encoded string with a length limit of 128 characters. Otherwise, an `INVALID_ARGUMENT` error is returned.
      },
      "userPseudoId": "A String", # Required. A unique identifier for tracking visitors. For example, this could be implemented with an HTTP cookie, which should be able to uniquely identify a visitor on a single device. This unique identifier should not change if the visitor logs in or out of the website. This field should NOT have a fixed value such as `unknown_visitor`. This should be the same identifier as UserEvent.user_pseudo_id and SearchRequest.user_pseudo_id. The field must be a UTF-8 encoded string with a length limit of 128.
    }

      x__xgafv: string, V1 error format.
        Allowed values
          1 - v1 error format
          2 - v2 error format

    Returns:
      An object of the form:

        { # Response message for CompletionService.RemoveSuggestion method.
    }