// Code generated by sidekick. DO NOT EDIT.
//
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#if AssistantService || ConversationalSearchService || SearchService || ServingConfigService
  import Foundation
  import GoogleCloudWkt

  /// Request message for
  /// [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search]
  /// method.
  ///
  /// [google.cloud.discoveryengine.v1.SearchService.Search]: <doc:SearchService/search(request:)>
  public struct SearchRequest: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Required. The resource name of the Search serving config, such as
    /// `projects/*/locations/global/collections/default_collection/engines/*/servingConfigs/default_serving_config`,
    /// or
    /// `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/servingConfigs/default_serving_config`.
    /// This field is used to identify the serving configuration name, set
    /// of models used to make the search.
    public var servingConfig: Swift.String = Swift.String()

    /// The branch resource name, such as
    /// `projects/*/locations/global/collections/default_collection/dataStores/default_data_store/branches/0`.
    ///
    /// Use `default_branch` as the branch ID or leave this field empty, to search
    /// documents under the default branch.
    public var branch: Swift.String = Swift.String()

    /// Raw search query.
    public var query: Swift.String = Swift.String()

    /// Optional. The categories associated with a category page. Must be set for
    /// category navigation queries to achieve good search quality. The format
    /// should be the same as
    /// [PageInfo.page_category][google.cloud.discoveryengine.v1.PageInfo.page_category].
    /// This field is the equivalent of the query for browse (navigation) queries.
    /// It's used by the browse model when the query is empty.
    ///
    /// If the field is empty, it will not be used by the browse model.
    /// If the field contains more than one element, only the first element will
    /// be used.
    ///
    /// To represent full path of a category, use '>' character to separate
    /// different hierarchies. If '>' is part of the category name, replace it with
    /// other character(s).
    /// For example, `Graphics Cards > RTX>4090 > Founders Edition` where "RTX >
    /// 4090" represents one level, can be rewritten as `Graphics Cards > RTX_4090
    /// > Founders Edition`
    ///
    /// [google.cloud.discoveryengine.v1.PageInfo.page_category]: <doc:PageInfo/pageCategory>
    public var pageCategories: [Swift.String] = []

    /// Raw image query.
    public var imageQuery: SearchRequest.ImageQuery? = nil

    /// Maximum number of [Document][google.cloud.discoveryengine.v1.Document]s to
    /// return. The maximum allowed value depends on the data type. Values above
    /// the maximum value are coerced to the maximum value.
    ///
    /// * Websites with basic indexing: Default `10`, Maximum `25`.
    /// * Websites with advanced indexing: Default `25`, Maximum `50`.
    /// * Other: Default `50`, Maximum `100`.
    ///
    /// If this field is negative, an  `INVALID_ARGUMENT` is returned.
    ///
    /// [google.cloud.discoveryengine.v1.Document]: <doc:Document>
    public var pageSize: Swift.Int32 = Swift.Int32()

    /// A page token received from a previous
    /// [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search]
    /// call. Provide this to retrieve the subsequent page.
    ///
    /// When paginating, all other parameters provided to
    /// [SearchService.Search][google.cloud.discoveryengine.v1.SearchService.Search]
    /// must match the call that provided the page token. Otherwise, an
    ///  `INVALID_ARGUMENT`  error is returned.
    ///
    /// [google.cloud.discoveryengine.v1.SearchService.Search]: <doc:SearchService/search(request:)>
    public var pageToken: Swift.String = Swift.String()

    /// A 0-indexed integer that specifies the current offset (that is, starting
    /// result location, amongst the
    /// [Document][google.cloud.discoveryengine.v1.Document]s deemed by the API as
    /// relevant) in search results. This field is only considered if
    /// [page_token][google.cloud.discoveryengine.v1.SearchRequest.page_token] is
    /// unset.
    ///
    /// If this field is negative, an  `INVALID_ARGUMENT`  is returned.
    ///
    /// A large offset may be capped to a reasonable threshold.
    ///
    /// [google.cloud.discoveryengine.v1.Document]: <doc:Document>
    /// [google.cloud.discoveryengine.v1.SearchRequest.page_token]: <doc:SearchRequest/pageToken>
    public var offset: Swift.Int32 = Swift.Int32()

    /// The maximum number of results to return for OneBox.
    /// This applies to each OneBox type individually.
    /// Default number is 10.
    public var oneBoxPageSize: Swift.Int32 = Swift.Int32()

    /// Specifications that define the specific
    /// [DataStore][google.cloud.discoveryengine.v1.DataStore]s to be searched,
    /// along with configurations for those data stores. This is only considered
    /// for [Engine][google.cloud.discoveryengine.v1.Engine]s with multiple data
    /// stores. For engines with a single data store, the specs directly under
    /// [SearchRequest][google.cloud.discoveryengine.v1.SearchRequest] should be
    /// used.
    ///
    /// [google.cloud.discoveryengine.v1.DataStore]: <doc:DataStore>
    /// [google.cloud.discoveryengine.v1.Engine]: <doc:Engine>
    /// [google.cloud.discoveryengine.v1.SearchRequest]: <doc:SearchRequest>
    public var dataStoreSpecs: [SearchRequest.DataStoreSpec] = []

    /// The filter syntax consists of an expression language for constructing a
    /// predicate from one or more fields of the documents being filtered. Filter
    /// expression is case-sensitive.
    ///
    /// If this field is unrecognizable, an  `INVALID_ARGUMENT`  is returned.
    ///
    /// Filtering in Vertex AI Search is done by mapping the LHS filter key to a
    /// key property defined in the Vertex AI Search backend -- this mapping is
    /// defined by the customer in their schema. For example a media customer might
    /// have a field 'name' in their schema. In this case the filter would look
    /// like this: filter --> name:'ANY("king kong")'
    ///
    /// For more information about filtering including syntax and filter
    /// operators, see
    /// [Filter](https://cloud.google.com/generative-ai-app-builder/docs/filter-search-metadata)
    public var filter: Swift.String = Swift.String()

    /// The default filter that is applied when a user performs a search without
    /// checking any filters on the search page.
    ///
    /// The filter applied to every search request when quality improvement such as
    /// query expansion is needed. In the case a query does not have a sufficient
    /// amount of results this filter will be used to determine whether or not to
    /// enable the query expansion flow. The original filter will still be used for
    /// the query expanded search.
    /// This field is strongly recommended to achieve high search quality.
    ///
    /// For more information about filter syntax, see
    /// [SearchRequest.filter][google.cloud.discoveryengine.v1.SearchRequest.filter].
    ///
    /// [google.cloud.discoveryengine.v1.SearchRequest.filter]: <doc:SearchRequest/filter>
    public var canonicalFilter: Swift.String = Swift.String()

    /// The order in which documents are returned. Documents can be ordered by
    /// a field in an [Document][google.cloud.discoveryengine.v1.Document] object.
    /// Leave it unset if ordered by relevance. `order_by` expression is
    /// case-sensitive.
    ///
    /// For more information on ordering the website search results, see
    /// [Order web search
    /// results](https://cloud.google.com/generative-ai-app-builder/docs/order-web-search-results).
    /// For more information on ordering the healthcare search results, see
    /// [Order healthcare search
    /// results](https://cloud.google.com/generative-ai-app-builder/docs/order-hc-results).
    /// If this field is unrecognizable, an `INVALID_ARGUMENT` is returned.
    ///
    /// [google.cloud.discoveryengine.v1.Document]: <doc:Document>
    public var orderBy: Swift.String = Swift.String()

    /// Information about the end user.
    /// Highly recommended for analytics and personalization.
    /// [UserInfo.user_agent][google.cloud.discoveryengine.v1.UserInfo.user_agent]
    /// is used to deduce `device_type` for analytics.
    ///
    /// [google.cloud.discoveryengine.v1.UserInfo.user_agent]: <doc:UserInfo/userAgent>
    public var userInfo: UserInfo? = nil

    /// The BCP-47 language code, such as "en-US" or "sr-Latn". For more
    /// information, see [Standard
    /// fields](https://cloud.google.com/apis/design/standard_fields). This field
    /// helps to better interpret the query. If a value isn't specified, the query
    /// language code is automatically detected, which may not be accurate.
    public var languageCode: Swift.String = Swift.String()

    /// Facet specifications for faceted search. If empty, no facets are returned.
    ///
    /// A maximum of 100 values are allowed. Otherwise, an  `INVALID_ARGUMENT`
    /// error is returned.
    public var facetSpecs: [SearchRequest.FacetSpec] = []

    /// Boost specification to boost certain documents.
    /// For more information on boosting, see
    /// [Boosting](https://cloud.google.com/generative-ai-app-builder/docs/boost-search-results)
    public var boostSpec: SearchRequest.BoostSpec? = nil

    /// Additional search parameters.
    ///
    /// For public website search only, supported values are:
    ///
    /// * `user_country_code`: string. Default empty. If set to non-empty, results
    ///    are restricted or boosted based on the location provided.
    ///    For example, `user_country_code: "au"`
    ///
    ///    For available codes see [Country
    ///    Codes](https://developers.google.com/custom-search/docs/json_api_reference#countryCodes)
    ///
    /// * `search_type`: double. Default empty. Enables non-webpage searching
    ///    depending on the value. The only valid non-default value is 1,
    ///    which enables image searching.
    ///    For example, `search_type: 1`
    public var params: [Swift.String: GoogleCloudWkt.Value] = [:]

    /// The query expansion specification that specifies the conditions under which
    /// query expansion occurs.
    public var queryExpansionSpec: SearchRequest.QueryExpansionSpec? = nil

    /// The spell correction specification that specifies the mode under
    /// which spell correction takes effect.
    public var spellCorrectionSpec: SearchRequest.SpellCorrectionSpec? = nil

    /// Optional. 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][google.cloud.discoveryengine.v1.UserEvent.user_pseudo_id]
    /// and
    /// [CompleteQueryRequest.user_pseudo_id][google.cloud.discoveryengine.v1.CompleteQueryRequest.user_pseudo_id]
    ///
    /// The field must be a UTF-8 encoded string with a length limit of 128
    /// characters. Otherwise, an  `INVALID_ARGUMENT`  error is returned.
    ///
    /// [google.cloud.discoveryengine.v1.CompleteQueryRequest.user_pseudo_id]: <doc:CompleteQueryRequest/userPseudoId>
    /// [google.cloud.discoveryengine.v1.UserEvent.user_pseudo_id]: <doc:UserEvent/userPseudoId>
    public var userPseudoId: Swift.String = Swift.String()

    /// A specification for configuring the behavior of content search.
    public var contentSearchSpec: SearchRequest.ContentSearchSpec? = nil

    /// Optional. The ranking expression controls the customized ranking on
    /// retrieval documents. This overrides
    /// [ServingConfig.ranking_expression][google.cloud.discoveryengine.v1.ServingConfig.ranking_expression].
    /// The syntax and supported features depend on the
    /// `ranking_expression_backend` value. If `ranking_expression_backend` is not
    /// provided, it defaults to `RANK_BY_EMBEDDING`.
    ///
    /// If
    /// [ranking_expression_backend][google.cloud.discoveryengine.v1.SearchRequest.ranking_expression_backend]
    /// is not provided or set to `RANK_BY_EMBEDDING`, it should be a single
    /// function or multiple functions that are joined by "+".
    ///
    ///   * ranking_expression = function, { " + ", function };
    ///
    /// Supported functions:
    ///
    ///   * double * relevance_score
    ///   * double * dotProduct(embedding_field_path)
    ///
    /// Function variables:
    ///
    ///   * `relevance_score`: pre-defined keywords, used for measure relevance
    ///   between query and document.
    ///   * `embedding_field_path`: the document embedding field
    ///   used with query embedding vector.
    ///   * `dotProduct`: embedding function between `embedding_field_path` and
    ///   query embedding vector.
    ///
    ///  Example ranking expression:
    ///
    ///    If document has an embedding field doc_embedding, the ranking expression
    ///    could be `0.5 * relevance_score + 0.3 * dotProduct(doc_embedding)`.
    ///
    /// If
    /// [ranking_expression_backend][google.cloud.discoveryengine.v1.SearchRequest.ranking_expression_backend]
    /// is set to `RANK_BY_FORMULA`, the following expression types (and
    /// combinations of those chained using + or
    /// * operators) are supported:
    ///
    ///   * `double`
    ///   * `signal`
    ///   * `log(signal)`
    ///   * `exp(signal)`
    ///   * `rr(signal, double > 0)`  -- reciprocal rank transformation with second
    ///   argument being a denominator constant.
    ///   * `is_nan(signal)` -- returns 0 if signal is NaN, 1 otherwise.
    ///   * `fill_nan(signal1, signal2 | double)` -- if signal1 is NaN, returns
    ///   signal2 | double, else returns signal1.
    ///
    ///   Here are a few examples of ranking formulas that use the supported
    ///   ranking expression types:
    ///
    ///   - `0.2 * semantic_similarity_score + 0.8 * log(keyword_similarity_score)`
    ///   -- mostly rank by the logarithm of `keyword_similarity_score` with slight
    ///   `semantic_smilarity_score` adjustment.
    ///   - `0.2 * exp(fill_nan(semantic_similarity_score, 0)) + 0.3 *
    ///   is_nan(keyword_similarity_score)` -- rank by the exponent of
    ///   `semantic_similarity_score` filling the value with 0 if it's NaN, also
    ///   add constant 0.3 adjustment to the final score if
    ///   `semantic_similarity_score` is NaN.
    ///   - `0.2 * rr(semantic_similarity_score, 16) + 0.8 *
    ///   rr(keyword_similarity_score, 16)` -- mostly rank by the reciprocal rank
    ///   of `keyword_similarity_score` with slight adjustment of reciprocal rank
    ///   of `semantic_smilarity_score`.
    ///
    /// The following signals are supported:
    ///
    ///   * `semantic_similarity_score`: semantic similarity adjustment that is
    ///   calculated using the embeddings generated by a proprietary Google model.
    ///   This score determines how semantically similar a search query is to a
    ///   document.
    ///   * `keyword_similarity_score`: keyword match adjustment uses the Best
    ///   Match 25 (BM25) ranking function. This score is calculated using a
    ///   probabilistic model to estimate the probability that a document is
    ///   relevant to a given query.
    ///   * `relevance_score`: semantic relevance adjustment that uses a
    ///   proprietary Google model to determine the meaning and intent behind a
    ///   user's query in context with the content in the documents.
    ///   * `pctr_rank`: predicted conversion rate adjustment as a rank use
    ///   predicted Click-through rate (pCTR) to gauge the relevance and
    ///   attractiveness of a search result from a user's perspective. A higher
    ///   pCTR suggests that the result is more likely to satisfy the user's query
    ///   and intent, making it a valuable signal for ranking.
    ///   * `freshness_rank`: freshness adjustment as a rank
    ///   * `document_age`: The time in hours elapsed since the document was last
    ///   updated, a floating-point number (e.g., 0.25 means 15 minutes).
    ///   * `topicality_rank`: topicality adjustment as a rank. Uses proprietary
    ///   Google model to determine the keyword-based overlap between the query and
    ///   the document.
    ///   * `base_rank`: the default rank of the result
    ///
    /// [google.cloud.discoveryengine.v1.SearchRequest.ranking_expression_backend]: <doc:SearchRequest/rankingExpressionBackend>
    /// [google.cloud.discoveryengine.v1.ServingConfig.ranking_expression]: <doc:ServingConfig/rankingExpression>
    public var rankingExpression: Swift.String = Swift.String()

    /// Optional. The backend to use for the ranking expression evaluation.
    public var rankingExpressionBackend: SearchRequest.RankingExpressionBackend =
      SearchRequest.RankingExpressionBackend()

    /// Whether to turn on safe search. This is only supported for
    /// website search.
    public var safeSearch: Swift.Bool = Swift.Bool()

    /// The user labels applied to a resource must meet the following requirements:
    ///
    /// * Each resource can have multiple labels, up to a maximum of 64.
    /// * Each label must be a key-value pair.
    /// * Keys have a minimum length of 1 character and a maximum length of 63
    ///   characters and cannot be empty. Values can be empty and have a maximum
    ///   length of 63 characters.
    /// * Keys and values can contain only lowercase letters, numeric characters,
    ///   underscores, and dashes. All characters must use UTF-8 encoding, and
    ///   international characters are allowed.
    /// * The key portion of a label must be unique. However, you can use the same
    ///   key with multiple resources.
    /// * Keys must start with a lowercase letter or international character.
    ///
    /// See [Google Cloud
    /// Document](https://cloud.google.com/resource-manager/docs/creating-managing-labels#requirements)
    /// for more details.
    public var userLabels: [Swift.String: Swift.String] = [:]

    /// Optional. Config for natural language query understanding capabilities,
    /// such as extracting structured field filters from the query. Refer to [this
    /// documentation](https://cloud.google.com/generative-ai-app-builder/docs/natural-language-queries)
    /// for more information.
    /// If `naturalLanguageQueryUnderstandingSpec` is not specified, no additional
    /// natural language query understanding will be done.
    public var naturalLanguageQueryUnderstandingSpec:
      SearchRequest.NaturalLanguageQueryUnderstandingSpec? = nil

    /// Search as you type configuration. Only supported for the
    /// [IndustryVertical.MEDIA][google.cloud.discoveryengine.v1.IndustryVertical.MEDIA]
    /// vertical.
    ///
    /// [google.cloud.discoveryengine.v1.IndustryVertical.MEDIA]: <doc:IndustryVertical/media>
    public var searchAsYouTypeSpec: SearchRequest.SearchAsYouTypeSpec? = nil

    /// Optional. Config for display feature, like match highlighting on search
    /// results.
    public var displaySpec: SearchRequest.DisplaySpec? = nil

    /// Optional. Crowding specifications for improving result diversity.
    /// If multiple CrowdingSpecs are specified, crowding will be evaluated on
    /// each unique combination of the `field` values, and max_count will be the
    /// maximum value of `max_count` across all CrowdingSpecs.
    /// For example, if the first CrowdingSpec has `field` = "color" and
    /// `max_count` = 3, and the second CrowdingSpec has `field` = "size" and
    /// `max_count` = 2, then after 3 documents that share the same color AND size
    /// have been returned, subsequent ones should be
    /// removed or demoted.
    public var crowdingSpecs: [SearchRequest.CrowdingSpec] = []

    /// The session resource name. Optional.
    ///
    /// Session allows users to do multi-turn /search API calls or coordination
    /// between /search API calls and /answer API calls.
    ///
    /// Example #1 (multi-turn /search API calls):
    ///   Call /search API with the session ID generated in the first call.
    ///   Here, the previous search query gets considered in query
    ///   standing. I.e., if the first query is "How did Alphabet do in 2022?"
    ///   and the current query is "How about 2023?", the current query will
    ///   be interpreted as "How did Alphabet do in 2023?".
    ///
    /// Example #2 (coordination between /search API calls and /answer API calls):
    ///   Call /answer API with the session ID generated in the first call.
    ///   Here, the answer generation happens in the context of the search
    ///   results from the first search call.
    ///
    /// Multi-turn Search feature is currently at private GA stage. Please use
    /// v1alpha or v1beta version instead before we launch this feature to public
    /// GA. Or ask for allowlisting through Google Support team.
    public var session: Swift.String = Swift.String()

    /// Session specification.
    ///
    /// Can be used only when `session` is set.
    public var sessionSpec: SearchRequest.SessionSpec? = nil

    /// The global relevance threshold of the search results.
    ///
    /// Defaults to Google defined threshold, leveraging a balance of
    /// precision and recall to deliver both highly accurate results and
    /// comprehensive coverage of relevant information.
    ///
    /// If more granular relevance filtering is required, use the
    /// `relevance_filter_spec` instead.
    ///
    /// This feature is not supported for healthcare search.
    public var relevanceThreshold: SearchRequest.RelevanceThreshold =
      SearchRequest.RelevanceThreshold()

    /// Optional. The granular relevance filtering specification.
    ///
    /// If not specified, the global `relevance_threshold` will be used for all
    /// sub-searches. If specified, this overrides the global
    /// `relevance_threshold` to use thresholds on a per sub-search basis.
    ///
    /// This feature is currently supported only for custom and site search.
    public var relevanceFilterSpec: SearchRequest.RelevanceFilterSpec? = nil

    /// Optional. The specification for returning the relevance score.
    public var relevanceScoreSpec: SearchRequest.RelevanceScoreSpec? = nil

    /// Initialize a new instance of `SearchRequest`.
    public init() {}

    /// Use `config` to return a new instance of this object, with some fields updated.
    ///
    /// Commonly used to initialize the value, for example:
    ///
    /// ```
    /// let value = SearchRequest().with { $0.servingConfig = ... }
    /// ```
    public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
      var copy = self
      try config(&copy)
      return copy
    }

    /// Specifies the image query input.
    public struct ImageQuery: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      public var image: OneOf_Image? = nil

      /// Initialize a new instance of `ImageQuery`.
      public init() {}

      /// Use `config` to return a new instance of this object, with some fields updated.
      ///
      /// Commonly used to initialize the value, for example:
      ///
      /// ```
      /// let value = ImageQuery().with { $0.imageBytes = ... }
      /// ```
      public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
        var copy = self
        try config(&copy)
        return copy
      }

      private enum CodingKeys: Swift.String, CodingKey {
        case imageBytes = "imageBytes"
      }

      public init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)

        var image: OneOf_Image? = nil
        let imageCheckAndSet = {
          if image != nil {
            throw DecodingError.dataCorrupted(
              DecodingError.Context(
                codingPath: decoder.codingPath,
                debugDescription: "Multiple values set for oneof 'image'"))
          }
          image = $0
        }
        if let imageBytes = try container.decodeIfPresent(Swift.String.self, forKey: .imageBytes) {
          try imageCheckAndSet(.imageBytes(imageBytes))
        }
        self.image = image
      }

      public func encode(to encoder: Encoder) throws {
        var container = encoder.container(keyedBy: CodingKeys.self)

        if let choice = self.image {
          switch choice {
          case .imageBytes(let value):
            try container.encode(value, forKey: .imageBytes)
          }
        }
      }

      public enum OneOf_Image: Codable, Equatable, Sendable {
        /// Base64 encoded image bytes. Supported image formats: JPEG, PNG, and
        /// BMP.
        case imageBytes(Swift.String)
      }

      public static var _anyTypeUrl: Swift.String {
        return "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.ImageQuery"
      }
      public init(fromAny any: GoogleCloudWkt.`Any`) throws {
        self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
      }
      public func _pack() throws -> GoogleCloudWkt.Struct {
        return try GoogleCloudWkt._slowAnySerialize(message: self)
      }
    }

    /// A struct to define data stores to filter on in a search call and
    /// configurations for those data stores. Otherwise, an `INVALID_ARGUMENT`
    /// error is returned.
    public struct DataStoreSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Required. Full resource name of
      /// [DataStore][google.cloud.discoveryengine.v1.DataStore], such as
      /// `projects/{project}/locations/{location}/collections/{collection_id}/dataStores/{data_store_id}`.
      /// The path must include the project number, project id is not supported for
      /// this field.
      ///
      /// [google.cloud.discoveryengine.v1.DataStore]: <doc:DataStore>
      public var dataStore: Swift.String = Swift.String()

      /// Optional. Filter specification to filter documents in the data store
      /// specified by data_store field. For more information on filtering, see
      /// [Filtering](https://cloud.google.com/generative-ai-app-builder/docs/filter-search-metadata)
      public var filter: Swift.String = Swift.String()

      /// Optional. Boost specification to boost certain documents.
      /// For more information on boosting, see
      /// [Boosting](https://cloud.google.com/generative-ai-app-builder/docs/boost-search-results)
      public var boostSpec: SearchRequest.BoostSpec? = nil

      /// Optional. Custom search operators which if specified will be used to
      /// filter results from workspace data stores. For more information on custom
      /// search operators, see
      /// [SearchOperators](https://support.google.com/cloudsearch/answer/6172299).
      public var customSearchOperators: Swift.String = Swift.String()

      /// Initialize a new instance of `DataStoreSpec`.
      public init() {}

      /// Use `config` to return a new instance of this object, with some fields updated.
      ///
      /// Commonly used to initialize the value, for example:
      ///
      /// ```
      /// let value = DataStoreSpec().with { $0.dataStore = ... }
      /// ```
      public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
        var copy = self
        try config(&copy)
        return copy
      }

      public static var _anyTypeUrl: Swift.String {
        return "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.DataStoreSpec"
      }
      public init(fromAny any: GoogleCloudWkt.`Any`) throws {
        self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
      }
      public func _pack() throws -> GoogleCloudWkt.Struct {
        return try GoogleCloudWkt._slowAnySerialize(message: self)
      }
    }

    /// A facet specification to perform faceted search.
    public struct FacetSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Required. The facet key specification.
      public var facetKey: SearchRequest.FacetSpec.FacetKey? = nil

      /// Maximum facet values that are returned for this facet. If
      /// unspecified, defaults to 20. The maximum allowed value is 300. Values
      /// above 300 are coerced to 300.
      /// For aggregation in healthcare search, when the [FacetKey.key] is
      /// "healthcare_aggregation_key", the limit will be overridden to
      /// 10,000 internally, regardless of the value set here.
      ///
      /// If this field is negative, an  `INVALID_ARGUMENT`  is returned.
      public var limit: Swift.Int32 = Swift.Int32()

      /// List of keys to exclude when faceting.
      ///
      /// By default,
      /// [FacetKey.key][google.cloud.discoveryengine.v1.SearchRequest.FacetSpec.FacetKey.key]
      /// is not excluded from the filter unless it is listed in this field.
      ///
      /// Listing a facet key in this field allows its values to appear as facet
      /// results, even when they are filtered out of search results. Using this
      /// field does not affect what search results are returned.
      ///
      /// For example, suppose there are 100 documents with the color facet "Red"
      /// and 200 documents with the color facet "Blue". A query containing the
      /// filter "color:ANY("Red")" and having "color" as
      /// [FacetKey.key][google.cloud.discoveryengine.v1.SearchRequest.FacetSpec.FacetKey.key]
      /// would by default return only "Red" documents in the search results, and
      /// also return "Red" with count 100 as the only color facet. Although there
      /// are also blue documents available, "Blue" would not be shown as an
      /// available facet value.
      ///
      /// If "color" is listed in "excludedFilterKeys", then the query returns the
      /// facet values "Red" with count 100 and "Blue" with count 200, because the
      /// "color" key is now excluded from the filter. Because this field doesn't
      /// affect search results, the search results are still correctly filtered to
      /// return only "Red" documents.
      ///
      /// A maximum of 100 values are allowed. Otherwise, an  `INVALID_ARGUMENT`
      /// error is returned.
      ///
      /// [google.cloud.discoveryengine.v1.SearchRequest.FacetSpec.FacetKey.key]: <doc:SearchRequest/FacetSpec/FacetKey/key>
      public var excludedFilterKeys: [Swift.String] = []

      /// Enables dynamic position for this facet. If set to true, the position of
      /// this facet among all facets in the response is determined automatically.
      /// If dynamic facets are enabled, it is ordered together.
      /// If set to false, the position of this facet in the
      /// response is the same as in the request, and it is ranked before
      /// the facets with dynamic position enable and all dynamic facets.
      ///
      /// For example, you may always want to have rating facet returned in
      /// the response, but it's not necessarily to always display the rating facet
      /// at the top. In that case, you can set enable_dynamic_position to true so
      /// that the position of rating facet in response is determined
      /// automatically.
      ///
      /// Another example, assuming you have the following facets in the request:
      ///
      /// * "rating", enable_dynamic_position = true
      ///
      /// * "price", enable_dynamic_position = false
      ///
      /// * "brands", enable_dynamic_position = false
      ///
      /// And also you have a dynamic facets enabled, which generates a facet
      /// `gender`. Then the final order of the facets in the response can be
      /// ("price", "brands", "rating", "gender") or ("price", "brands", "gender",
      /// "rating") depends on how API orders "gender" and "rating" facets.
      /// However, notice that "price" and "brands" are always
      /// ranked at first and second position because their enable_dynamic_position
      /// is false.
      public var enableDynamicPosition: Swift.Bool = Swift.Bool()

      /// Initialize a new instance of `FacetSpec`.
      public init() {}

      /// Use `config` to return a new instance of this object, with some fields updated.
      ///
      /// Commonly used to initialize the value, for example:
      ///
      /// ```
      /// let value = FacetSpec().with { $0.facetKey = ... }
      /// ```
      public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
        var copy = self
        try config(&copy)
        return copy
      }

      /// Specifies how a facet is computed.
      public struct FacetKey: Codable, Equatable, GoogleCloudWkt._AnyPackable,
        Sendable
      {
        /// Required. Supported textual and numerical facet keys in
        /// [Document][google.cloud.discoveryengine.v1.Document] object, over which
        /// the facet values are computed. Facet key is case-sensitive.
        ///
        /// [google.cloud.discoveryengine.v1.Document]: <doc:Document>
        public var key: Swift.String = Swift.String()

        /// Set only if values should be bucketed into intervals. Must be set
        /// for facets with numerical values. Must not be set for facet with text
        /// values. Maximum number of intervals is 30.
        public var intervals: [Interval] = []

        /// Only get facet for the given restricted values. Only supported on
        /// textual fields. For example, suppose "category" has three values
        /// "Action > 2022", "Action > 2021" and "Sci-Fi > 2022". If set
        /// "restricted_values" to "Action > 2022", the "category" facet only
        /// contains "Action > 2022". Only supported on textual fields. Maximum
        /// is 10.
        public var restrictedValues: [Swift.String] = []

        /// Only get facet values that start with the given string prefix. For
        /// example, suppose "category" has three values "Action > 2022",
        /// "Action > 2021" and "Sci-Fi > 2022". If set "prefixes" to "Action", the
        /// "category" facet only contains "Action > 2022" and "Action > 2021".
        /// Only supported on textual fields. Maximum is 10.
        public var prefixes: [Swift.String] = []

        /// Only get facet values that contain the given strings. For example,
        /// suppose "category" has three values "Action > 2022",
        /// "Action > 2021" and "Sci-Fi > 2022". If set "contains" to "2022", the
        /// "category" facet only contains "Action > 2022" and "Sci-Fi > 2022".
        /// Only supported on textual fields. Maximum is 10.
        public var contains: [Swift.String] = []

        /// True to make facet keys case insensitive when getting faceting
        /// values with prefixes or contains; false otherwise.
        public var caseInsensitive: Swift.Bool = Swift.Bool()

        /// The order in which documents are returned.
        ///
        /// Allowed values are:
        ///
        /// * "count desc", which means order by
        /// [SearchResponse.Facet.values.count][google.cloud.discoveryengine.v1.SearchResponse.Facet.FacetValue.count]
        /// descending.
        ///
        /// * "value desc", which means order by
        /// [SearchResponse.Facet.values.value][google.cloud.discoveryengine.v1.SearchResponse.Facet.FacetValue.value]
        /// descending.
        ///   Only applies to textual facets.
        ///
        /// If not set, textual values are sorted in [natural
        /// order](https://en.wikipedia.org/wiki/Natural_sort_order); numerical
        /// intervals are sorted in the order given by
        /// [FacetSpec.FacetKey.intervals][google.cloud.discoveryengine.v1.SearchRequest.FacetSpec.FacetKey.intervals].
        ///
        /// [google.cloud.discoveryengine.v1.SearchRequest.FacetSpec.FacetKey.intervals]: <doc:SearchRequest/FacetSpec/FacetKey/intervals>
        /// [google.cloud.discoveryengine.v1.SearchResponse.Facet.FacetValue.count]: <doc:SearchResponse/Facet/FacetValue/count>
        /// [google.cloud.discoveryengine.v1.SearchResponse.Facet.FacetValue.value]: <doc:SearchResponse/Facet/FacetValue/value>
        public var orderBy: Swift.String = Swift.String()

        /// Initialize a new instance of `FacetKey`.
        public init() {}

        /// Use `config` to return a new instance of this object, with some fields updated.
        ///
        /// Commonly used to initialize the value, for example:
        ///
        /// ```
        /// let value = FacetKey().with { $0.key = ... }
        /// ```
        public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
          var copy = self
          try config(&copy)
          return copy
        }

        public static var _anyTypeUrl: Swift.String {
          return
            "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.FacetSpec.FacetKey"
        }
        public init(fromAny any: GoogleCloudWkt.`Any`) throws {
          self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
        }
        public func _pack() throws -> GoogleCloudWkt.Struct {
          return try GoogleCloudWkt._slowAnySerialize(message: self)
        }
      }

      public static var _anyTypeUrl: Swift.String {
        return "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.FacetSpec"
      }
      public init(fromAny any: GoogleCloudWkt.`Any`) throws {
        self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
      }
      public func _pack() throws -> GoogleCloudWkt.Struct {
        return try GoogleCloudWkt._slowAnySerialize(message: self)
      }
    }

    /// Boost specification to boost certain documents.
    public struct BoostSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Condition boost specifications. If a document matches multiple conditions
      /// in the specifications, boost scores from these specifications are all
      /// applied and combined in a non-linear way. Maximum number of
      /// specifications is 20.
      public var conditionBoostSpecs: [SearchRequest.BoostSpec.ConditionBoostSpec] = []

      /// Initialize a new instance of `BoostSpec`.
      public init() {}

      /// Use `config` to return a new instance of this object, with some fields updated.
      ///
      /// Commonly used to initialize the value, for example:
      ///
      /// ```
      /// let value = BoostSpec().with { $0.conditionBoostSpecs = ... }
      /// ```
      public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
        var copy = self
        try config(&copy)
        return copy
      }

      /// Boost applies to documents which match a condition.
      public struct ConditionBoostSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
        Sendable
      {
        /// An expression which specifies a boost condition. The syntax and
        /// supported fields are the same as a filter expression. See
        /// [SearchRequest.filter][google.cloud.discoveryengine.v1.SearchRequest.filter]
        /// for detail syntax and limitations.
        ///
        /// Examples:
        ///
        /// * To boost documents with document ID "doc_1" or "doc_2", and
        /// color "Red" or "Blue":
        /// `(document_id: ANY("doc_1", "doc_2")) AND (color: ANY("Red", "Blue"))`
        ///
        /// [google.cloud.discoveryengine.v1.SearchRequest.filter]: <doc:SearchRequest/filter>
        public var condition: Swift.String = Swift.String()

        /// Strength of the condition boost, which should be in [-1, 1]. Negative
        /// boost means demotion. Default is 0.0.
        ///
        /// Setting to 1.0 gives the document a big promotion. However, it does
        /// not necessarily mean that the boosted document will be the top result
        /// at all times, nor that other documents will be excluded. Results
        /// could still be shown even when none of them matches the condition.
        /// And results that are significantly more relevant to the search query
        /// can still trump your heavily favored but irrelevant documents.
        ///
        /// Setting to -1.0 gives the document a big demotion. However, results
        /// that are deeply relevant might still be shown. The document will have
        /// an upstream battle to get a fairly high ranking, but it is not
        /// blocked out completely.
        ///
        /// Setting to 0.0 means no boost applied. The boosting condition is
        /// ignored. Only one of the (condition, boost) combination or the
        /// boost_control_spec below are set. If both are set then the global boost
        /// is ignored and the more fine-grained boost_control_spec is applied.
        public var boost: Swift.Float = Swift.Float()

        /// Complex specification for custom ranking based on customer defined
        /// attribute value.
        public var boostControlSpec: SearchRequest.BoostSpec.ConditionBoostSpec.BoostControlSpec? =
          nil

        /// Initialize a new instance of `ConditionBoostSpec`.
        public init() {}

        /// Use `config` to return a new instance of this object, with some fields updated.
        ///
        /// Commonly used to initialize the value, for example:
        ///
        /// ```
        /// let value = ConditionBoostSpec().with { $0.condition = ... }
        /// ```
        public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
          var copy = self
          try config(&copy)
          return copy
        }

        /// Specification for custom ranking based on customer specified attribute
        /// value. It provides more controls for customized ranking than the simple
        /// (condition, boost) combination above.
        public struct BoostControlSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
          Sendable
        {
          /// The name of the field whose value will be used to determine the
          /// boost amount.
          public var fieldName: Swift.String = Swift.String()

          /// The attribute type to be used to determine the boost amount. The
          /// attribute value can be derived from the field value of the specified
          /// field_name. In the case of numerical it is straightforward i.e.
          /// attribute_value = numerical_field_value. In the case of freshness
          /// however, attribute_value = (time.now() - datetime_field_value).
          public var attributeType:
            SearchRequest.BoostSpec.ConditionBoostSpec.BoostControlSpec.AttributeType =
              SearchRequest.BoostSpec.ConditionBoostSpec.BoostControlSpec.AttributeType()

          /// The interpolation type to be applied to connect the control points
          /// listed below.
          public var interpolationType:
            SearchRequest.BoostSpec.ConditionBoostSpec.BoostControlSpec.InterpolationType =
              SearchRequest.BoostSpec.ConditionBoostSpec.BoostControlSpec.InterpolationType()

          /// The control points used to define the curve. The monotonic function
          /// (defined through the interpolation_type above) passes through the
          /// control points listed here.
          public var controlPoints:
            [SearchRequest.BoostSpec.ConditionBoostSpec.BoostControlSpec.ControlPoint] = []

          /// Initialize a new instance of `BoostControlSpec`.
          public init() {}

          /// Use `config` to return a new instance of this object, with some fields updated.
          ///
          /// Commonly used to initialize the value, for example:
          ///
          /// ```
          /// let value = BoostControlSpec().with { $0.fieldName = ... }
          /// ```
          public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
            var copy = self
            try config(&copy)
            return copy
          }

          /// The control points used to define the curve. The curve defined
          /// through these control points can only be monotonically increasing
          /// or decreasing(constant values are acceptable).
          public struct ControlPoint: Codable, Equatable, GoogleCloudWkt._AnyPackable,
            Sendable
          {
            /// Can be one of:
            /// 1. The numerical field value.
            /// 2. The duration spec for freshness:
            /// The value must be formatted as an XSD `dayTimeDuration` value (a
            /// restricted subset of an ISO 8601 duration value). The pattern for
            /// this is: `[nD][T[nH][nM][nS]]`.
            public var attributeValue: Swift.String = Swift.String()

            /// The value between -1 to 1 by which to boost the score if the
            /// attribute_value evaluates to the value specified above.
            public var boostAmount: Swift.Float = Swift.Float()

            /// Initialize a new instance of `ControlPoint`.
            public init() {}

            /// Use `config` to return a new instance of this object, with some fields updated.
            ///
            /// Commonly used to initialize the value, for example:
            ///
            /// ```
            /// let value = ControlPoint().with { $0.attributeValue = ... }
            /// ```
            public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
              var copy = self
              try config(&copy)
              return copy
            }

            public static var _anyTypeUrl: Swift.String {
              return
                "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.BoostSpec.ConditionBoostSpec.BoostControlSpec.ControlPoint"
            }
            public init(fromAny any: GoogleCloudWkt.`Any`) throws {
              self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
            }
            public func _pack() throws -> GoogleCloudWkt.Struct {
              return try GoogleCloudWkt._slowAnySerialize(message: self)
            }
          }

          /// The attribute(or function) for which the custom ranking is to be
          /// applied.
          public enum AttributeType: Codable, Equatable, Sendable {
            /// Unspecified AttributeType.
            case unspecified
            /// The value of the numerical field will be used to dynamically update
            /// the boost amount. In this case, the attribute_value (the x value)
            /// of the control point will be the actual value of the numerical
            /// field for which the boost_amount is specified.
            case numerical
            /// For the freshness use case the attribute value will be the duration
            /// between the current time and the date in the datetime field
            /// specified. The value must be formatted as an XSD `dayTimeDuration`
            /// value (a restricted subset of an ISO 8601 duration value). The
            /// pattern for this is: `[nD][T[nH][nM][nS]]`.
            /// For example, `5D`, `3DT12H30M`, `T24H`.
            case freshness
            /// Encodes an unknown integer value.
            ///
            /// The most common cause for an unknown values is for the service to send
            /// a value unknown to the library. We recommend you update your library to
            /// the latest version.
            case unknownIntValue(Int)
            /// Encodes an unknown string value.
            ///
            /// The most common cause for an unknown values is for the service to send
            /// a value unknown to the library. We recommend you update your library to
            /// the latest version.
            case unknownStringValue(String)

            public init() {
              self = .unspecified
            }

            /// Returns the integer value associated with the enumeration.
            ///
            /// If the enumeration was initialized with an unknown string value, this returns `nil`.
            public var intValue: Int? {
              switch self {
              case .unspecified: return 0
              case .numerical: return 1
              case .freshness: return 2
              case .unknownIntValue(let v): return v
              case .unknownStringValue: return nil
              }
            }

            /// Returns the string value (or name) associated with the enumeration.
            ///
            /// If the enumeration was initialized with an unknown integer value, this returns `nil`.
            public var stringValue: Swift.String? {
              switch self {
              case .unspecified: return "ATTRIBUTE_TYPE_UNSPECIFIED"
              case .numerical: return "NUMERICAL"
              case .freshness: return "FRESHNESS"
              case .unknownIntValue: return nil
              case .unknownStringValue(let v): return v
              }
            }

            /// Initialize from a string value.
            ///
            /// If the value is unknown, this initializes to [`unknownStringValue`](doc:AttributeType/unknownStringValue(_:)).
            public init(stringValue: Swift.String) {
              switch stringValue {
              case "ATTRIBUTE_TYPE_UNSPECIFIED": self = .unspecified
              case "NUMERICAL": self = .numerical
              case "FRESHNESS": self = .freshness
              default: self = .unknownStringValue(stringValue)
              }
            }

            /// Initialize from an integer value.
            ///
            /// If the value is unknown, this initializes to [`unknownIntValue`](doc:AttributeType/unknownIntValue(_:)).
            public init(intValue: Int) {
              switch intValue {
              case 0: self = .unspecified
              case 1: self = .numerical
              case 2: self = .freshness
              default: self = .unknownIntValue(intValue)
              }
            }

            public init(from decoder: Decoder) throws {
              let container = try decoder.singleValueContainer()
              if let v = try? container.decode(Int.self) {
                self.init(intValue: v)
                return
              }
              if let s = try? container.decode(String.self) {
                if let v = Int(s) {
                  self.init(intValue: v)
                } else {
                  self.init(stringValue: s)
                }
                return
              }
              throw DecodingError.dataCorruptedError(
                in: container, debugDescription: "Expected enum value, must be integer or string.")
            }

            public func encode(to encoder: Encoder) throws {
              var container = encoder.singleValueContainer()
              switch self {
              case .unspecified: return try container.encode(0)
              case .numerical: return try container.encode(1)
              case .freshness: return try container.encode(2)
              case .unknownIntValue(let v): return try container.encode(v)
              case .unknownStringValue(let v): return try container.encode(v)
              }
            }
          }

          /// The interpolation type to be applied. Default will be linear
          /// (Piecewise Linear).
          public enum InterpolationType: Codable, Equatable, Sendable {
            /// Interpolation type is unspecified. In this case, it defaults to
            /// Linear.
            case unspecified
            /// Piecewise linear interpolation will be applied.
            case linear
            /// Encodes an unknown integer value.
            ///
            /// The most common cause for an unknown values is for the service to send
            /// a value unknown to the library. We recommend you update your library to
            /// the latest version.
            case unknownIntValue(Int)
            /// Encodes an unknown string value.
            ///
            /// The most common cause for an unknown values is for the service to send
            /// a value unknown to the library. We recommend you update your library to
            /// the latest version.
            case unknownStringValue(String)

            public init() {
              self = .unspecified
            }

            /// Returns the integer value associated with the enumeration.
            ///
            /// If the enumeration was initialized with an unknown string value, this returns `nil`.
            public var intValue: Int? {
              switch self {
              case .unspecified: return 0
              case .linear: return 1
              case .unknownIntValue(let v): return v
              case .unknownStringValue: return nil
              }
            }

            /// Returns the string value (or name) associated with the enumeration.
            ///
            /// If the enumeration was initialized with an unknown integer value, this returns `nil`.
            public var stringValue: Swift.String? {
              switch self {
              case .unspecified: return "INTERPOLATION_TYPE_UNSPECIFIED"
              case .linear: return "LINEAR"
              case .unknownIntValue: return nil
              case .unknownStringValue(let v): return v
              }
            }

            /// Initialize from a string value.
            ///
            /// If the value is unknown, this initializes to [`unknownStringValue`](doc:InterpolationType/unknownStringValue(_:)).
            public init(stringValue: Swift.String) {
              switch stringValue {
              case "INTERPOLATION_TYPE_UNSPECIFIED": self = .unspecified
              case "LINEAR": self = .linear
              default: self = .unknownStringValue(stringValue)
              }
            }

            /// Initialize from an integer value.
            ///
            /// If the value is unknown, this initializes to [`unknownIntValue`](doc:InterpolationType/unknownIntValue(_:)).
            public init(intValue: Int) {
              switch intValue {
              case 0: self = .unspecified
              case 1: self = .linear
              default: self = .unknownIntValue(intValue)
              }
            }

            public init(from decoder: Decoder) throws {
              let container = try decoder.singleValueContainer()
              if let v = try? container.decode(Int.self) {
                self.init(intValue: v)
                return
              }
              if let s = try? container.decode(String.self) {
                if let v = Int(s) {
                  self.init(intValue: v)
                } else {
                  self.init(stringValue: s)
                }
                return
              }
              throw DecodingError.dataCorruptedError(
                in: container, debugDescription: "Expected enum value, must be integer or string.")
            }

            public func encode(to encoder: Encoder) throws {
              var container = encoder.singleValueContainer()
              switch self {
              case .unspecified: return try container.encode(0)
              case .linear: return try container.encode(1)
              case .unknownIntValue(let v): return try container.encode(v)
              case .unknownStringValue(let v): return try container.encode(v)
              }
            }
          }

          public static var _anyTypeUrl: Swift.String {
            return
              "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.BoostSpec.ConditionBoostSpec.BoostControlSpec"
          }
          public init(fromAny any: GoogleCloudWkt.`Any`) throws {
            self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
          }
          public func _pack() throws -> GoogleCloudWkt.Struct {
            return try GoogleCloudWkt._slowAnySerialize(message: self)
          }
        }

        public static var _anyTypeUrl: Swift.String {
          return
            "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.BoostSpec.ConditionBoostSpec"
        }
        public init(fromAny any: GoogleCloudWkt.`Any`) throws {
          self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
        }
        public func _pack() throws -> GoogleCloudWkt.Struct {
          return try GoogleCloudWkt._slowAnySerialize(message: self)
        }
      }

      public static var _anyTypeUrl: Swift.String {
        return "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.BoostSpec"
      }
      public init(fromAny any: GoogleCloudWkt.`Any`) throws {
        self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
      }
      public func _pack() throws -> GoogleCloudWkt.Struct {
        return try GoogleCloudWkt._slowAnySerialize(message: self)
      }
    }

    /// Specification to determine under which conditions query expansion should
    /// occur.
    public struct QueryExpansionSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// The condition under which query expansion should occur. Default to
      /// [Condition.DISABLED][google.cloud.discoveryengine.v1.SearchRequest.QueryExpansionSpec.Condition.DISABLED].
      ///
      /// [google.cloud.discoveryengine.v1.SearchRequest.QueryExpansionSpec.Condition.DISABLED]: <doc:SearchRequest/QueryExpansionSpec/Condition/disabled>
      public var condition: SearchRequest.QueryExpansionSpec.Condition = SearchRequest
        .QueryExpansionSpec.Condition()

      /// Whether to pin unexpanded results. If this field is set to true,
      /// unexpanded products are always at the top of the search results, followed
      /// by the expanded results.
      public var pinUnexpandedResults: Swift.Bool = Swift.Bool()

      /// Initialize a new instance of `QueryExpansionSpec`.
      public init() {}

      /// Use `config` to return a new instance of this object, with some fields updated.
      ///
      /// Commonly used to initialize the value, for example:
      ///
      /// ```
      /// let value = QueryExpansionSpec().with { $0.condition = ... }
      /// ```
      public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
        var copy = self
        try config(&copy)
        return copy
      }

      /// Enum describing under which condition query expansion should occur.
      public enum Condition: Codable, Equatable, Sendable {
        /// Unspecified query expansion condition. In this case, server behavior
        /// defaults to
        /// [Condition.DISABLED][google.cloud.discoveryengine.v1.SearchRequest.QueryExpansionSpec.Condition.DISABLED].
        ///
        /// [google.cloud.discoveryengine.v1.SearchRequest.QueryExpansionSpec.Condition.DISABLED]: <doc:SearchRequest/QueryExpansionSpec/Condition/disabled>
        case unspecified
        /// Disabled query expansion. Only the exact search query is used, even if
        /// [SearchResponse.total_size][google.cloud.discoveryengine.v1.SearchResponse.total_size]
        /// is zero.
        ///
        /// [google.cloud.discoveryengine.v1.SearchResponse.total_size]: <doc:SearchResponse/totalSize>
        case disabled
        /// Automatic query expansion built by the Search API.
        case auto
        /// Encodes an unknown integer value.
        ///
        /// The most common cause for an unknown values is for the service to send
        /// a value unknown to the library. We recommend you update your library to
        /// the latest version.
        case unknownIntValue(Int)
        /// Encodes an unknown string value.
        ///
        /// The most common cause for an unknown values is for the service to send
        /// a value unknown to the library. We recommend you update your library to
        /// the latest version.
        case unknownStringValue(String)

        public init() {
          self = .unspecified
        }

        /// Returns the integer value associated with the enumeration.
        ///
        /// If the enumeration was initialized with an unknown string value, this returns `nil`.
        public var intValue: Int? {
          switch self {
          case .unspecified: return 0
          case .disabled: return 1
          case .auto: return 2
          case .unknownIntValue(let v): return v
          case .unknownStringValue: return nil
          }
        }

        /// Returns the string value (or name) associated with the enumeration.
        ///
        /// If the enumeration was initialized with an unknown integer value, this returns `nil`.
        public var stringValue: Swift.String? {
          switch self {
          case .unspecified: return "CONDITION_UNSPECIFIED"
          case .disabled: return "DISABLED"
          case .auto: return "AUTO"
          case .unknownIntValue: return nil
          case .unknownStringValue(let v): return v
          }
        }

        /// Initialize from a string value.
        ///
        /// If the value is unknown, this initializes to [`unknownStringValue`](doc:Condition/unknownStringValue(_:)).
        public init(stringValue: Swift.String) {
          switch stringValue {
          case "CONDITION_UNSPECIFIED": self = .unspecified
          case "DISABLED": self = .disabled
          case "AUTO": self = .auto
          default: self = .unknownStringValue(stringValue)
          }
        }

        /// Initialize from an integer value.
        ///
        /// If the value is unknown, this initializes to [`unknownIntValue`](doc:Condition/unknownIntValue(_:)).
        public init(intValue: Int) {
          switch intValue {
          case 0: self = .unspecified
          case 1: self = .disabled
          case 2: self = .auto
          default: self = .unknownIntValue(intValue)
          }
        }

        public init(from decoder: Decoder) throws {
          let container = try decoder.singleValueContainer()
          if let v = try? container.decode(Int.self) {
            self.init(intValue: v)
            return
          }
          if let s = try? container.decode(String.self) {
            if let v = Int(s) {
              self.init(intValue: v)
            } else {
              self.init(stringValue: s)
            }
            return
          }
          throw DecodingError.dataCorruptedError(
            in: container, debugDescription: "Expected enum value, must be integer or string.")
        }

        public func encode(to encoder: Encoder) throws {
          var container = encoder.singleValueContainer()
          switch self {
          case .unspecified: return try container.encode(0)
          case .disabled: return try container.encode(1)
          case .auto: return try container.encode(2)
          case .unknownIntValue(let v): return try container.encode(v)
          case .unknownStringValue(let v): return try container.encode(v)
          }
        }
      }

      public static var _anyTypeUrl: Swift.String {
        return
          "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.QueryExpansionSpec"
      }
      public init(fromAny any: GoogleCloudWkt.`Any`) throws {
        self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
      }
      public func _pack() throws -> GoogleCloudWkt.Struct {
        return try GoogleCloudWkt._slowAnySerialize(message: self)
      }
    }

    /// The specification for query spell correction.
    public struct SpellCorrectionSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// The mode under which spell correction
      /// replaces the original search query. Defaults to
      /// [Mode.AUTO][google.cloud.discoveryengine.v1.SearchRequest.SpellCorrectionSpec.Mode.AUTO].
      ///
      /// [google.cloud.discoveryengine.v1.SearchRequest.SpellCorrectionSpec.Mode.AUTO]: <doc:SearchRequest/SpellCorrectionSpec/Mode/auto>
      public var mode: SearchRequest.SpellCorrectionSpec.Mode = SearchRequest.SpellCorrectionSpec
        .Mode()

      /// Initialize a new instance of `SpellCorrectionSpec`.
      public init() {}

      /// Use `config` to return a new instance of this object, with some fields updated.
      ///
      /// Commonly used to initialize the value, for example:
      ///
      /// ```
      /// let value = SpellCorrectionSpec().with { $0.mode = ... }
      /// ```
      public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
        var copy = self
        try config(&copy)
        return copy
      }

      /// Enum describing under which mode spell correction should occur.
      public enum Mode: Codable, Equatable, Sendable {
        /// Unspecified spell correction mode. In this case, server behavior
        /// defaults to
        /// [Mode.AUTO][google.cloud.discoveryengine.v1.SearchRequest.SpellCorrectionSpec.Mode.AUTO].
        ///
        /// [google.cloud.discoveryengine.v1.SearchRequest.SpellCorrectionSpec.Mode.AUTO]: <doc:SearchRequest/SpellCorrectionSpec/Mode/auto>
        case unspecified
        /// Search API tries to find a spelling suggestion. If a suggestion is
        /// found, it is put in the
        /// [SearchResponse.corrected_query][google.cloud.discoveryengine.v1.SearchResponse.corrected_query].
        /// The spelling suggestion won't be used as the search query.
        ///
        /// [google.cloud.discoveryengine.v1.SearchResponse.corrected_query]: <doc:SearchResponse/correctedQuery>
        case suggestionOnly
        /// Automatic spell correction built by the Search API. Search will
        /// be based on the corrected query if found.
        case auto
        /// Encodes an unknown integer value.
        ///
        /// The most common cause for an unknown values is for the service to send
        /// a value unknown to the library. We recommend you update your library to
        /// the latest version.
        case unknownIntValue(Int)
        /// Encodes an unknown string value.
        ///
        /// The most common cause for an unknown values is for the service to send
        /// a value unknown to the library. We recommend you update your library to
        /// the latest version.
        case unknownStringValue(String)

        public init() {
          self = .unspecified
        }

        /// Returns the integer value associated with the enumeration.
        ///
        /// If the enumeration was initialized with an unknown string value, this returns `nil`.
        public var intValue: Int? {
          switch self {
          case .unspecified: return 0
          case .suggestionOnly: return 1
          case .auto: return 2
          case .unknownIntValue(let v): return v
          case .unknownStringValue: return nil
          }
        }

        /// Returns the string value (or name) associated with the enumeration.
        ///
        /// If the enumeration was initialized with an unknown integer value, this returns `nil`.
        public var stringValue: Swift.String? {
          switch self {
          case .unspecified: return "MODE_UNSPECIFIED"
          case .suggestionOnly: return "SUGGESTION_ONLY"
          case .auto: return "AUTO"
          case .unknownIntValue: return nil
          case .unknownStringValue(let v): return v
          }
        }

        /// Initialize from a string value.
        ///
        /// If the value is unknown, this initializes to [`unknownStringValue`](doc:Mode/unknownStringValue(_:)).
        public init(stringValue: Swift.String) {
          switch stringValue {
          case "MODE_UNSPECIFIED": self = .unspecified
          case "SUGGESTION_ONLY": self = .suggestionOnly
          case "AUTO": self = .auto
          default: self = .unknownStringValue(stringValue)
          }
        }

        /// Initialize from an integer value.
        ///
        /// If the value is unknown, this initializes to [`unknownIntValue`](doc:Mode/unknownIntValue(_:)).
        public init(intValue: Int) {
          switch intValue {
          case 0: self = .unspecified
          case 1: self = .suggestionOnly
          case 2: self = .auto
          default: self = .unknownIntValue(intValue)
          }
        }

        public init(from decoder: Decoder) throws {
          let container = try decoder.singleValueContainer()
          if let v = try? container.decode(Int.self) {
            self.init(intValue: v)
            return
          }
          if let s = try? container.decode(String.self) {
            if let v = Int(s) {
              self.init(intValue: v)
            } else {
              self.init(stringValue: s)
            }
            return
          }
          throw DecodingError.dataCorruptedError(
            in: container, debugDescription: "Expected enum value, must be integer or string.")
        }

        public func encode(to encoder: Encoder) throws {
          var container = encoder.singleValueContainer()
          switch self {
          case .unspecified: return try container.encode(0)
          case .suggestionOnly: return try container.encode(1)
          case .auto: return try container.encode(2)
          case .unknownIntValue(let v): return try container.encode(v)
          case .unknownStringValue(let v): return try container.encode(v)
          }
        }
      }

      public static var _anyTypeUrl: Swift.String {
        return
          "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.SpellCorrectionSpec"
      }
      public init(fromAny any: GoogleCloudWkt.`Any`) throws {
        self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
      }
      public func _pack() throws -> GoogleCloudWkt.Struct {
        return try GoogleCloudWkt._slowAnySerialize(message: self)
      }
    }

    /// A specification for configuring the behavior of content search.
    public struct ContentSearchSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// If `snippetSpec` is not specified, snippets are not included in the
      /// search response.
      public var snippetSpec: SearchRequest.ContentSearchSpec.SnippetSpec? = nil

      /// If `summarySpec` is not specified, summaries are not included in the
      /// search response.
      public var summarySpec: SearchRequest.ContentSearchSpec.SummarySpec? = nil

      /// If there is no extractive_content_spec provided, there will be no
      /// extractive answer in the search response.
      public var extractiveContentSpec: SearchRequest.ContentSearchSpec.ExtractiveContentSpec? = nil

      /// Specifies the search result mode. If unspecified, the
      /// search result mode defaults to `DOCUMENTS`.
      public var searchResultMode: SearchRequest.ContentSearchSpec.SearchResultMode = SearchRequest
        .ContentSearchSpec.SearchResultMode()

      /// Specifies the chunk spec to be returned from the search response.
      /// Only available if the
      /// [SearchRequest.ContentSearchSpec.search_result_mode][google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec.search_result_mode]
      /// is set to
      /// [CHUNKS][google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec.SearchResultMode.CHUNKS]
      ///
      /// [google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec.SearchResultMode.CHUNKS]: <doc:SearchRequest/ContentSearchSpec/SearchResultMode/chunks>
      /// [google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec.search_result_mode]: <doc:SearchRequest/ContentSearchSpec/searchResultMode>
      public var chunkSpec: SearchRequest.ContentSearchSpec.ChunkSpec? = nil

      /// Initialize a new instance of `ContentSearchSpec`.
      public init() {}

      /// Use `config` to return a new instance of this object, with some fields updated.
      ///
      /// Commonly used to initialize the value, for example:
      ///
      /// ```
      /// let value = ContentSearchSpec().with { $0.snippetSpec = ... }
      /// ```
      public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
        var copy = self
        try config(&copy)
        return copy
      }

      /// A specification for configuring snippets in a search response.
      public struct SnippetSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
        Sendable
      {
        /// [DEPRECATED] This field is deprecated. To control snippet return, use
        /// `return_snippet` field. For backwards compatibility, we will return
        /// snippet if max_snippet_count > 0.
        @available(*, deprecated)
        public var maxSnippetCount: Swift.Int32 = Swift.Int32()

        /// [DEPRECATED] This field is deprecated and will have no affect on the
        /// snippet.
        @available(*, deprecated)
        public var referenceOnly: Swift.Bool = Swift.Bool()

        /// If `true`, then return snippet. If no snippet can be generated, we
        /// return "No snippet is available for this page." A `snippet_status` with
        /// `SUCCESS` or `NO_SNIPPET_AVAILABLE` will also be returned.
        public var returnSnippet: Swift.Bool = Swift.Bool()

        /// Initialize a new instance of `SnippetSpec`.
        public init() {}

        /// Use `config` to return a new instance of this object, with some fields updated.
        ///
        /// Commonly used to initialize the value, for example:
        ///
        /// ```
        /// let value = SnippetSpec().with { $0.maxSnippetCount = ... }
        /// ```
        public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
          var copy = self
          try config(&copy)
          return copy
        }

        public static var _anyTypeUrl: Swift.String {
          return
            "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec.SnippetSpec"
        }
        public init(fromAny any: GoogleCloudWkt.`Any`) throws {
          self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
        }
        public func _pack() throws -> GoogleCloudWkt.Struct {
          return try GoogleCloudWkt._slowAnySerialize(message: self)
        }
      }

      /// A specification for configuring a summary returned in a search
      /// response.
      public struct SummarySpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
        Sendable
      {
        /// The number of top results to generate the summary from. If the number
        /// of results returned is less than `summaryResultCount`, the summary is
        /// generated from all of the results.
        ///
        /// At most 10 results for documents mode, or 50 for chunks mode, can be
        /// used to generate a summary. The chunks mode is used when
        /// [SearchRequest.ContentSearchSpec.search_result_mode][google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec.search_result_mode]
        /// is set to
        /// [CHUNKS][google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec.SearchResultMode.CHUNKS].
        ///
        /// [google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec.SearchResultMode.CHUNKS]: <doc:SearchRequest/ContentSearchSpec/SearchResultMode/chunks>
        /// [google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec.search_result_mode]: <doc:SearchRequest/ContentSearchSpec/searchResultMode>
        public var summaryResultCount: Swift.Int32 = Swift.Int32()

        /// Specifies whether to include citations in the summary. The default
        /// value is `false`.
        ///
        /// When this field is set to `true`, summaries include in-line citation
        /// numbers.
        ///
        /// Example summary including citations:
        ///
        /// BigQuery is Google Cloud's fully managed and completely serverless
        /// enterprise data warehouse [1]. BigQuery supports all data types, works
        /// across clouds, and has built-in machine learning and business
        /// intelligence, all within a unified platform [2, 3].
        ///
        /// The citation numbers refer to the returned search results and are
        /// 1-indexed. For example, [1] means that the sentence is attributed to
        /// the first search result. [2, 3] means that the sentence is attributed
        /// to both the second and third search results.
        public var includeCitations: Swift.Bool = Swift.Bool()

        /// Specifies whether to filter out adversarial queries. The default value
        /// is `false`.
        ///
        /// Google employs search-query classification to detect adversarial
        /// queries. No summary is returned if the search query is classified as an
        /// adversarial query. For example, a user might ask a question regarding
        /// negative comments about the company or submit a query designed to
        /// generate unsafe, policy-violating output. If this field is set to
        /// `true`, we skip generating summaries for adversarial queries and return
        /// fallback messages instead.
        public var ignoreAdversarialQuery: Swift.Bool = Swift.Bool()

        /// Specifies whether to filter out queries that are not summary-seeking.
        /// The default value is `false`.
        ///
        /// Google employs search-query classification to detect summary-seeking
        /// queries. No summary is returned if the search query is classified as a
        /// non-summary seeking query. For example, `why is the sky blue` and `Who
        /// is the best soccer player in the world?` are summary-seeking queries,
        /// but `SFO airport` and `world cup 2026` are not. They are most likely
        /// navigational queries. If this field is set to `true`, we skip
        /// generating summaries for non-summary seeking queries and return
        /// fallback messages instead.
        public var ignoreNonSummarySeekingQuery: Swift.Bool = Swift.Bool()

        /// Specifies whether to filter out queries that have low relevance. The
        /// default value is `false`.
        ///
        /// If this field is set to `false`, all search results are used regardless
        /// of relevance to generate answers. If set to `true`, only queries with
        /// high relevance search results will generate answers.
        public var ignoreLowRelevantContent: Swift.Bool = Swift.Bool()

        /// Optional. Specifies whether to filter out jail-breaking queries. The
        /// default value is `false`.
        ///
        /// Google employs search-query classification to detect jail-breaking
        /// queries. No summary is returned if the search query is classified as a
        /// jail-breaking query. A user might add instructions to the query to
        /// change the tone, style, language, content of the answer, or ask the
        /// model to act as a different entity, e.g. "Reply in the tone of a
        /// competing company's CEO". If this field is set to `true`, we skip
        /// generating summaries for jail-breaking queries and return fallback
        /// messages instead.
        public var ignoreJailBreakingQuery: Swift.Bool = Swift.Bool()

        /// If specified, the spec will be used to modify the prompt provided to
        /// the LLM.
        public var modelPromptSpec: SearchRequest.ContentSearchSpec.SummarySpec.ModelPromptSpec? =
          nil

        /// Language code for Summary. Use language tags defined by
        /// [BCP47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt).
        /// Note: This is an experimental feature.
        public var languageCode: Swift.String = Swift.String()

        /// If specified, the spec will be used to modify the model specification
        /// provided to the LLM.
        public var modelSpec: SearchRequest.ContentSearchSpec.SummarySpec.ModelSpec? = nil

        /// If true, answer will be generated from most relevant chunks from top
        /// search results. This feature will improve summary quality.
        /// Note that with this feature enabled, not all top search results
        /// will be referenced and included in the reference list, so the citation
        /// source index only points to the search results listed in the reference
        /// list.
        public var useSemanticChunks: Swift.Bool = Swift.Bool()

        /// Initialize a new instance of `SummarySpec`.
        public init() {}

        /// Use `config` to return a new instance of this object, with some fields updated.
        ///
        /// Commonly used to initialize the value, for example:
        ///
        /// ```
        /// let value = SummarySpec().with { $0.summaryResultCount = ... }
        /// ```
        public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
          var copy = self
          try config(&copy)
          return copy
        }

        /// Specification of the prompt to use with the model.
        public struct ModelPromptSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
          Sendable
        {
          /// Text at the beginning of the prompt that instructs the assistant.
          /// Examples are available in the user guide.
          public var preamble: Swift.String = Swift.String()

          /// Initialize a new instance of `ModelPromptSpec`.
          public init() {}

          /// Use `config` to return a new instance of this object, with some fields updated.
          ///
          /// Commonly used to initialize the value, for example:
          ///
          /// ```
          /// let value = ModelPromptSpec().with { $0.preamble = ... }
          /// ```
          public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
            var copy = self
            try config(&copy)
            return copy
          }

          public static var _anyTypeUrl: Swift.String {
            return
              "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec.SummarySpec.ModelPromptSpec"
          }
          public init(fromAny any: GoogleCloudWkt.`Any`) throws {
            self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
          }
          public func _pack() throws -> GoogleCloudWkt.Struct {
            return try GoogleCloudWkt._slowAnySerialize(message: self)
          }
        }

        /// Specification of the model.
        public struct ModelSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
          Sendable
        {
          /// The model version used to generate the summary.
          ///
          /// Supported values are:
          ///
          /// * `stable`: string. Default value when no value is specified. Uses a
          ///    generally available, fine-tuned model. For more information, see
          ///    [Answer generation model versions and
          ///    lifecycle](https://cloud.google.com/generative-ai-app-builder/docs/answer-generation-models).
          /// * `preview`: string. (Public preview) Uses a preview model. For more
          ///    information, see
          ///    [Answer generation model versions and
          ///    lifecycle](https://cloud.google.com/generative-ai-app-builder/docs/answer-generation-models).
          public var version: Swift.String = Swift.String()

          /// Initialize a new instance of `ModelSpec`.
          public init() {}

          /// Use `config` to return a new instance of this object, with some fields updated.
          ///
          /// Commonly used to initialize the value, for example:
          ///
          /// ```
          /// let value = ModelSpec().with { $0.version = ... }
          /// ```
          public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
            var copy = self
            try config(&copy)
            return copy
          }

          public static var _anyTypeUrl: Swift.String {
            return
              "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec.SummarySpec.ModelSpec"
          }
          public init(fromAny any: GoogleCloudWkt.`Any`) throws {
            self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
          }
          public func _pack() throws -> GoogleCloudWkt.Struct {
            return try GoogleCloudWkt._slowAnySerialize(message: self)
          }
        }

        public static var _anyTypeUrl: Swift.String {
          return
            "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec.SummarySpec"
        }
        public init(fromAny any: GoogleCloudWkt.`Any`) throws {
          self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
        }
        public func _pack() throws -> GoogleCloudWkt.Struct {
          return try GoogleCloudWkt._slowAnySerialize(message: self)
        }
      }

      /// A specification for configuring the extractive content in a search
      /// response.
      public struct ExtractiveContentSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
        Sendable
      {
        /// The maximum number of extractive answers returned in each search
        /// result.
        ///
        /// An extractive answer is a verbatim answer extracted from the original
        /// document, which provides a precise and contextually relevant answer to
        /// the search query.
        ///
        /// If the number of matching answers is less than the
        /// `max_extractive_answer_count`, return all of the answers. Otherwise,
        /// return the `max_extractive_answer_count`.
        ///
        /// At most five answers are returned for each
        /// [SearchResult][google.cloud.discoveryengine.v1.SearchResponse.SearchResult].
        ///
        /// [google.cloud.discoveryengine.v1.SearchResponse.SearchResult]: <doc:SearchResponse/SearchResult>
        public var maxExtractiveAnswerCount: Swift.Int32 = Swift.Int32()

        /// The max number of extractive segments returned in each search result.
        /// Only applied if the
        /// [DataStore][google.cloud.discoveryengine.v1.DataStore] is set to
        /// [DataStore.ContentConfig.CONTENT_REQUIRED][google.cloud.discoveryengine.v1.DataStore.ContentConfig.CONTENT_REQUIRED]
        /// or
        /// [DataStore.solution_types][google.cloud.discoveryengine.v1.DataStore.solution_types]
        /// is
        /// [SOLUTION_TYPE_CHAT][google.cloud.discoveryengine.v1.SolutionType.SOLUTION_TYPE_CHAT].
        ///
        /// An extractive segment is a text segment extracted from the original
        /// document that is relevant to the search query, and, in general, more
        /// verbose than an extractive answer. The segment could then be used as
        /// input for LLMs to generate summaries and answers.
        ///
        /// If the number of matching segments is less than
        /// `max_extractive_segment_count`, return all of the segments. Otherwise,
        /// return the `max_extractive_segment_count`.
        ///
        /// [google.cloud.discoveryengine.v1.DataStore]: <doc:DataStore>
        /// [google.cloud.discoveryengine.v1.DataStore.ContentConfig.CONTENT_REQUIRED]: <doc:DataStore/ContentConfig/contentRequired>
        /// [google.cloud.discoveryengine.v1.DataStore.solution_types]: <doc:DataStore/solutionTypes>
        /// [google.cloud.discoveryengine.v1.SolutionType.SOLUTION_TYPE_CHAT]: <doc:SolutionType/chat>
        public var maxExtractiveSegmentCount: Swift.Int32 = Swift.Int32()

        /// Specifies whether to return the confidence score from the extractive
        /// segments in each search result. This feature is available only for new
        /// or allowlisted data stores. To allowlist your data store,
        /// contact your Customer Engineer. The default value is `false`.
        public var returnExtractiveSegmentScore: Swift.Bool = Swift.Bool()

        /// Specifies whether to also include the adjacent from each selected
        /// segments.
        /// Return at most `num_previous_segments` segments before each selected
        /// segments.
        public var numPreviousSegments: Swift.Int32 = Swift.Int32()

        /// Return at most `num_next_segments` segments after each selected
        /// segments.
        public var numNextSegments: Swift.Int32 = Swift.Int32()

        /// Initialize a new instance of `ExtractiveContentSpec`.
        public init() {}

        /// Use `config` to return a new instance of this object, with some fields updated.
        ///
        /// Commonly used to initialize the value, for example:
        ///
        /// ```
        /// let value = ExtractiveContentSpec().with { $0.maxExtractiveAnswerCount = ... }
        /// ```
        public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
          var copy = self
          try config(&copy)
          return copy
        }

        public static var _anyTypeUrl: Swift.String {
          return
            "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec.ExtractiveContentSpec"
        }
        public init(fromAny any: GoogleCloudWkt.`Any`) throws {
          self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
        }
        public func _pack() throws -> GoogleCloudWkt.Struct {
          return try GoogleCloudWkt._slowAnySerialize(message: self)
        }
      }

      /// Specifies the chunk spec to be returned from the search response.
      /// Only available if the
      /// [SearchRequest.ContentSearchSpec.search_result_mode][google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec.search_result_mode]
      /// is set to
      /// [CHUNKS][google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec.SearchResultMode.CHUNKS]
      ///
      /// [google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec.SearchResultMode.CHUNKS]: <doc:SearchRequest/ContentSearchSpec/SearchResultMode/chunks>
      /// [google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec.search_result_mode]: <doc:SearchRequest/ContentSearchSpec/searchResultMode>
      public struct ChunkSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
        Sendable
      {
        /// The number of previous chunks to be returned of the current chunk. The
        /// maximum allowed value is 3.
        /// If not specified, no previous chunks will be returned.
        public var numPreviousChunks: Swift.Int32 = Swift.Int32()

        /// The number of next chunks to be returned of the current chunk. The
        /// maximum allowed value is 3.
        /// If not specified, no next chunks will be returned.
        public var numNextChunks: Swift.Int32 = Swift.Int32()

        /// Initialize a new instance of `ChunkSpec`.
        public init() {}

        /// Use `config` to return a new instance of this object, with some fields updated.
        ///
        /// Commonly used to initialize the value, for example:
        ///
        /// ```
        /// let value = ChunkSpec().with { $0.numPreviousChunks = ... }
        /// ```
        public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
          var copy = self
          try config(&copy)
          return copy
        }

        public static var _anyTypeUrl: Swift.String {
          return
            "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec.ChunkSpec"
        }
        public init(fromAny any: GoogleCloudWkt.`Any`) throws {
          self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
        }
        public func _pack() throws -> GoogleCloudWkt.Struct {
          return try GoogleCloudWkt._slowAnySerialize(message: self)
        }
      }

      /// Specifies the search result mode. If unspecified, the
      /// search result mode defaults to `DOCUMENTS`.
      public enum SearchResultMode: Codable, Equatable, Sendable {
        /// Default value.
        case unspecified
        /// Returns documents in the search result.
        case documents
        /// Returns chunks in the search result. Only available if the
        /// [DocumentProcessingConfig.chunking_config][google.cloud.discoveryengine.v1.DocumentProcessingConfig.chunking_config]
        /// is specified.
        ///
        /// [google.cloud.discoveryengine.v1.DocumentProcessingConfig.chunking_config]: <doc:DocumentProcessingConfig/chunkingConfig>
        case chunks
        /// Encodes an unknown integer value.
        ///
        /// The most common cause for an unknown values is for the service to send
        /// a value unknown to the library. We recommend you update your library to
        /// the latest version.
        case unknownIntValue(Int)
        /// Encodes an unknown string value.
        ///
        /// The most common cause for an unknown values is for the service to send
        /// a value unknown to the library. We recommend you update your library to
        /// the latest version.
        case unknownStringValue(String)

        public init() {
          self = .unspecified
        }

        /// Returns the integer value associated with the enumeration.
        ///
        /// If the enumeration was initialized with an unknown string value, this returns `nil`.
        public var intValue: Int? {
          switch self {
          case .unspecified: return 0
          case .documents: return 1
          case .chunks: return 2
          case .unknownIntValue(let v): return v
          case .unknownStringValue: return nil
          }
        }

        /// Returns the string value (or name) associated with the enumeration.
        ///
        /// If the enumeration was initialized with an unknown integer value, this returns `nil`.
        public var stringValue: Swift.String? {
          switch self {
          case .unspecified: return "SEARCH_RESULT_MODE_UNSPECIFIED"
          case .documents: return "DOCUMENTS"
          case .chunks: return "CHUNKS"
          case .unknownIntValue: return nil
          case .unknownStringValue(let v): return v
          }
        }

        /// Initialize from a string value.
        ///
        /// If the value is unknown, this initializes to [`unknownStringValue`](doc:SearchResultMode/unknownStringValue(_:)).
        public init(stringValue: Swift.String) {
          switch stringValue {
          case "SEARCH_RESULT_MODE_UNSPECIFIED": self = .unspecified
          case "DOCUMENTS": self = .documents
          case "CHUNKS": self = .chunks
          default: self = .unknownStringValue(stringValue)
          }
        }

        /// Initialize from an integer value.
        ///
        /// If the value is unknown, this initializes to [`unknownIntValue`](doc:SearchResultMode/unknownIntValue(_:)).
        public init(intValue: Int) {
          switch intValue {
          case 0: self = .unspecified
          case 1: self = .documents
          case 2: self = .chunks
          default: self = .unknownIntValue(intValue)
          }
        }

        public init(from decoder: Decoder) throws {
          let container = try decoder.singleValueContainer()
          if let v = try? container.decode(Int.self) {
            self.init(intValue: v)
            return
          }
          if let s = try? container.decode(String.self) {
            if let v = Int(s) {
              self.init(intValue: v)
            } else {
              self.init(stringValue: s)
            }
            return
          }
          throw DecodingError.dataCorruptedError(
            in: container, debugDescription: "Expected enum value, must be integer or string.")
        }

        public func encode(to encoder: Encoder) throws {
          var container = encoder.singleValueContainer()
          switch self {
          case .unspecified: return try container.encode(0)
          case .documents: return try container.encode(1)
          case .chunks: return try container.encode(2)
          case .unknownIntValue(let v): return try container.encode(v)
          case .unknownStringValue(let v): return try container.encode(v)
          }
        }
      }

      public static var _anyTypeUrl: Swift.String {
        return "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec"
      }
      public init(fromAny any: GoogleCloudWkt.`Any`) throws {
        self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
      }
      public func _pack() throws -> GoogleCloudWkt.Struct {
        return try GoogleCloudWkt._slowAnySerialize(message: self)
      }
    }

    /// Specification to enable natural language understanding capabilities for
    /// search requests.
    public struct NaturalLanguageQueryUnderstandingSpec: Codable, Equatable, GoogleCloudWkt
        ._AnyPackable,
      Sendable
    {
      /// The condition under which filter extraction should occur.
      /// Server behavior defaults to `DISABLED`.
      public var filterExtractionCondition:
        SearchRequest.NaturalLanguageQueryUnderstandingSpec.FilterExtractionCondition =
          SearchRequest.NaturalLanguageQueryUnderstandingSpec.FilterExtractionCondition()

      /// Field names used for location-based filtering, where geolocation filters
      /// are detected in natural language search queries.
      /// Only valid when the FilterExtractionCondition is set to `ENABLED`.
      ///
      /// If this field is set, it overrides the field names set in
      /// [ServingConfig.geo_search_query_detection_field_names][google.cloud.discoveryengine.v1.ServingConfig.geo_search_query_detection_field_names].
      public var geoSearchQueryDetectionFieldNames: [Swift.String] = []

      /// Optional. Controls behavior of how extracted filters are applied to the
      /// search. The default behavior depends on the request. For single datastore
      /// structured search, the default is `HARD_FILTER`. For multi-datastore
      /// search, the default behavior is `SOFT_BOOST`.
      /// Location-based filters are always applied as hard filters, and the
      /// `SOFT_BOOST` setting will not affect them.
      /// This field is only used if
      /// [SearchRequest.NaturalLanguageQueryUnderstandingSpec.FilterExtractionCondition][google.cloud.discoveryengine.v1.SearchRequest.NaturalLanguageQueryUnderstandingSpec.FilterExtractionCondition]
      /// is set to
      /// [FilterExtractionCondition.ENABLED][google.cloud.discoveryengine.v1.SearchRequest.NaturalLanguageQueryUnderstandingSpec.FilterExtractionCondition.ENABLED].
      ///
      /// [google.cloud.discoveryengine.v1.SearchRequest.NaturalLanguageQueryUnderstandingSpec.FilterExtractionCondition]: <doc:SearchRequest/NaturalLanguageQueryUnderstandingSpec/FilterExtractionCondition>
      /// [google.cloud.discoveryengine.v1.SearchRequest.NaturalLanguageQueryUnderstandingSpec.FilterExtractionCondition.ENABLED]: <doc:SearchRequest/NaturalLanguageQueryUnderstandingSpec/FilterExtractionCondition/enabled>
      public var extractedFilterBehavior:
        SearchRequest.NaturalLanguageQueryUnderstandingSpec.ExtractedFilterBehavior = SearchRequest
          .NaturalLanguageQueryUnderstandingSpec.ExtractedFilterBehavior()

      /// Optional. Allowlist of fields that can be used for natural language
      /// filter extraction. By default, if this is unspecified, all indexable
      /// fields are eligible for natural language filter extraction (but are not
      /// guaranteed to be used). If any fields are specified in
      /// allowed_field_names, only the fields that are both marked as indexable in
      /// the schema and specified in the allowlist will be eligible for natural
      /// language filter extraction. Note: for multi-datastore search, this is not
      /// yet supported, and will be ignored.
      public var allowedFieldNames: [Swift.String] = []

      /// Initialize a new instance of `NaturalLanguageQueryUnderstandingSpec`.
      public init() {}

      /// Use `config` to return a new instance of this object, with some fields updated.
      ///
      /// Commonly used to initialize the value, for example:
      ///
      /// ```
      /// let value = NaturalLanguageQueryUnderstandingSpec().with { $0.filterExtractionCondition = ... }
      /// ```
      public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
        var copy = self
        try config(&copy)
        return copy
      }

      /// Enum describing under which condition filter extraction should occur.
      public enum FilterExtractionCondition: Codable, Equatable, Sendable {
        /// Server behavior defaults to `DISABLED`.
        case conditionUnspecified
        /// Disables NL filter extraction.
        case disabled
        /// Enables NL filter extraction.
        case enabled
        /// Encodes an unknown integer value.
        ///
        /// The most common cause for an unknown values is for the service to send
        /// a value unknown to the library. We recommend you update your library to
        /// the latest version.
        case unknownIntValue(Int)
        /// Encodes an unknown string value.
        ///
        /// The most common cause for an unknown values is for the service to send
        /// a value unknown to the library. We recommend you update your library to
        /// the latest version.
        case unknownStringValue(String)

        public init() {
          self = .conditionUnspecified
        }

        /// Returns the integer value associated with the enumeration.
        ///
        /// If the enumeration was initialized with an unknown string value, this returns `nil`.
        public var intValue: Int? {
          switch self {
          case .conditionUnspecified: return 0
          case .disabled: return 1
          case .enabled: return 2
          case .unknownIntValue(let v): return v
          case .unknownStringValue: return nil
          }
        }

        /// Returns the string value (or name) associated with the enumeration.
        ///
        /// If the enumeration was initialized with an unknown integer value, this returns `nil`.
        public var stringValue: Swift.String? {
          switch self {
          case .conditionUnspecified: return "CONDITION_UNSPECIFIED"
          case .disabled: return "DISABLED"
          case .enabled: return "ENABLED"
          case .unknownIntValue: return nil
          case .unknownStringValue(let v): return v
          }
        }

        /// Initialize from a string value.
        ///
        /// If the value is unknown, this initializes to [`unknownStringValue`](doc:FilterExtractionCondition/unknownStringValue(_:)).
        public init(stringValue: Swift.String) {
          switch stringValue {
          case "CONDITION_UNSPECIFIED": self = .conditionUnspecified
          case "DISABLED": self = .disabled
          case "ENABLED": self = .enabled
          default: self = .unknownStringValue(stringValue)
          }
        }

        /// Initialize from an integer value.
        ///
        /// If the value is unknown, this initializes to [`unknownIntValue`](doc:FilterExtractionCondition/unknownIntValue(_:)).
        public init(intValue: Int) {
          switch intValue {
          case 0: self = .conditionUnspecified
          case 1: self = .disabled
          case 2: self = .enabled
          default: self = .unknownIntValue(intValue)
          }
        }

        public init(from decoder: Decoder) throws {
          let container = try decoder.singleValueContainer()
          if let v = try? container.decode(Int.self) {
            self.init(intValue: v)
            return
          }
          if let s = try? container.decode(String.self) {
            if let v = Int(s) {
              self.init(intValue: v)
            } else {
              self.init(stringValue: s)
            }
            return
          }
          throw DecodingError.dataCorruptedError(
            in: container, debugDescription: "Expected enum value, must be integer or string.")
        }

        public func encode(to encoder: Encoder) throws {
          var container = encoder.singleValueContainer()
          switch self {
          case .conditionUnspecified: return try container.encode(0)
          case .disabled: return try container.encode(1)
          case .enabled: return try container.encode(2)
          case .unknownIntValue(let v): return try container.encode(v)
          case .unknownStringValue(let v): return try container.encode(v)
          }
        }
      }

      /// Enum describing how extracted filters are applied to the search.
      public enum ExtractedFilterBehavior: Codable, Equatable, Sendable {
        /// `EXTRACTED_FILTER_BEHAVIOR_UNSPECIFIED` will use the default behavior
        /// for extracted filters. For single datastore search, the default is to
        /// apply as hard filters. For multi-datastore search, the default is to
        /// apply as soft boosts.
        case unspecified
        /// Applies all extracted filters as hard filters on the results. Results
        /// that do not pass the extracted filters will not be returned in the
        /// result set.
        case hardFilter
        /// Applies all extracted filters as soft boosts. Results that pass the
        /// filters will be boosted up to higher ranks in the result set.
        case softBoost
        /// Encodes an unknown integer value.
        ///
        /// The most common cause for an unknown values is for the service to send
        /// a value unknown to the library. We recommend you update your library to
        /// the latest version.
        case unknownIntValue(Int)
        /// Encodes an unknown string value.
        ///
        /// The most common cause for an unknown values is for the service to send
        /// a value unknown to the library. We recommend you update your library to
        /// the latest version.
        case unknownStringValue(String)

        public init() {
          self = .unspecified
        }

        /// Returns the integer value associated with the enumeration.
        ///
        /// If the enumeration was initialized with an unknown string value, this returns `nil`.
        public var intValue: Int? {
          switch self {
          case .unspecified: return 0
          case .hardFilter: return 1
          case .softBoost: return 2
          case .unknownIntValue(let v): return v
          case .unknownStringValue: return nil
          }
        }

        /// Returns the string value (or name) associated with the enumeration.
        ///
        /// If the enumeration was initialized with an unknown integer value, this returns `nil`.
        public var stringValue: Swift.String? {
          switch self {
          case .unspecified: return "EXTRACTED_FILTER_BEHAVIOR_UNSPECIFIED"
          case .hardFilter: return "HARD_FILTER"
          case .softBoost: return "SOFT_BOOST"
          case .unknownIntValue: return nil
          case .unknownStringValue(let v): return v
          }
        }

        /// Initialize from a string value.
        ///
        /// If the value is unknown, this initializes to [`unknownStringValue`](doc:ExtractedFilterBehavior/unknownStringValue(_:)).
        public init(stringValue: Swift.String) {
          switch stringValue {
          case "EXTRACTED_FILTER_BEHAVIOR_UNSPECIFIED": self = .unspecified
          case "HARD_FILTER": self = .hardFilter
          case "SOFT_BOOST": self = .softBoost
          default: self = .unknownStringValue(stringValue)
          }
        }

        /// Initialize from an integer value.
        ///
        /// If the value is unknown, this initializes to [`unknownIntValue`](doc:ExtractedFilterBehavior/unknownIntValue(_:)).
        public init(intValue: Int) {
          switch intValue {
          case 0: self = .unspecified
          case 1: self = .hardFilter
          case 2: self = .softBoost
          default: self = .unknownIntValue(intValue)
          }
        }

        public init(from decoder: Decoder) throws {
          let container = try decoder.singleValueContainer()
          if let v = try? container.decode(Int.self) {
            self.init(intValue: v)
            return
          }
          if let s = try? container.decode(String.self) {
            if let v = Int(s) {
              self.init(intValue: v)
            } else {
              self.init(stringValue: s)
            }
            return
          }
          throw DecodingError.dataCorruptedError(
            in: container, debugDescription: "Expected enum value, must be integer or string.")
        }

        public func encode(to encoder: Encoder) throws {
          var container = encoder.singleValueContainer()
          switch self {
          case .unspecified: return try container.encode(0)
          case .hardFilter: return try container.encode(1)
          case .softBoost: return try container.encode(2)
          case .unknownIntValue(let v): return try container.encode(v)
          case .unknownStringValue(let v): return try container.encode(v)
          }
        }
      }

      public static var _anyTypeUrl: Swift.String {
        return
          "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.NaturalLanguageQueryUnderstandingSpec"
      }
      public init(fromAny any: GoogleCloudWkt.`Any`) throws {
        self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
      }
      public func _pack() throws -> GoogleCloudWkt.Struct {
        return try GoogleCloudWkt._slowAnySerialize(message: self)
      }
    }

    /// Specification for search as you type in search requests.
    public struct SearchAsYouTypeSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// The condition under which search as you type should occur.
      /// Default to
      /// [Condition.DISABLED][google.cloud.discoveryengine.v1.SearchRequest.SearchAsYouTypeSpec.Condition.DISABLED].
      ///
      /// [google.cloud.discoveryengine.v1.SearchRequest.SearchAsYouTypeSpec.Condition.DISABLED]: <doc:SearchRequest/SearchAsYouTypeSpec/Condition/disabled>
      public var condition: SearchRequest.SearchAsYouTypeSpec.Condition = SearchRequest
        .SearchAsYouTypeSpec.Condition()

      /// Initialize a new instance of `SearchAsYouTypeSpec`.
      public init() {}

      /// Use `config` to return a new instance of this object, with some fields updated.
      ///
      /// Commonly used to initialize the value, for example:
      ///
      /// ```
      /// let value = SearchAsYouTypeSpec().with { $0.condition = ... }
      /// ```
      public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
        var copy = self
        try config(&copy)
        return copy
      }

      /// Enum describing under which condition search as you type should occur.
      public enum Condition: Codable, Equatable, Sendable {
        /// Server behavior defaults to
        /// [Condition.DISABLED][google.cloud.discoveryengine.v1.SearchRequest.SearchAsYouTypeSpec.Condition.DISABLED].
        ///
        /// [google.cloud.discoveryengine.v1.SearchRequest.SearchAsYouTypeSpec.Condition.DISABLED]: <doc:SearchRequest/SearchAsYouTypeSpec/Condition/disabled>
        case unspecified
        /// Disables Search As You Type.
        case disabled
        /// Enables Search As You Type.
        case enabled
        /// Automatic switching between search-as-you-type and standard search
        /// modes, ideal for single-API implementations (e.g., debouncing).
        case auto
        /// Encodes an unknown integer value.
        ///
        /// The most common cause for an unknown values is for the service to send
        /// a value unknown to the library. We recommend you update your library to
        /// the latest version.
        case unknownIntValue(Int)
        /// Encodes an unknown string value.
        ///
        /// The most common cause for an unknown values is for the service to send
        /// a value unknown to the library. We recommend you update your library to
        /// the latest version.
        case unknownStringValue(String)

        public init() {
          self = .unspecified
        }

        /// Returns the integer value associated with the enumeration.
        ///
        /// If the enumeration was initialized with an unknown string value, this returns `nil`.
        public var intValue: Int? {
          switch self {
          case .unspecified: return 0
          case .disabled: return 1
          case .enabled: return 2
          case .auto: return 3
          case .unknownIntValue(let v): return v
          case .unknownStringValue: return nil
          }
        }

        /// Returns the string value (or name) associated with the enumeration.
        ///
        /// If the enumeration was initialized with an unknown integer value, this returns `nil`.
        public var stringValue: Swift.String? {
          switch self {
          case .unspecified: return "CONDITION_UNSPECIFIED"
          case .disabled: return "DISABLED"
          case .enabled: return "ENABLED"
          case .auto: return "AUTO"
          case .unknownIntValue: return nil
          case .unknownStringValue(let v): return v
          }
        }

        /// Initialize from a string value.
        ///
        /// If the value is unknown, this initializes to [`unknownStringValue`](doc:Condition/unknownStringValue(_:)).
        public init(stringValue: Swift.String) {
          switch stringValue {
          case "CONDITION_UNSPECIFIED": self = .unspecified
          case "DISABLED": self = .disabled
          case "ENABLED": self = .enabled
          case "AUTO": self = .auto
          default: self = .unknownStringValue(stringValue)
          }
        }

        /// Initialize from an integer value.
        ///
        /// If the value is unknown, this initializes to [`unknownIntValue`](doc:Condition/unknownIntValue(_:)).
        public init(intValue: Int) {
          switch intValue {
          case 0: self = .unspecified
          case 1: self = .disabled
          case 2: self = .enabled
          case 3: self = .auto
          default: self = .unknownIntValue(intValue)
          }
        }

        public init(from decoder: Decoder) throws {
          let container = try decoder.singleValueContainer()
          if let v = try? container.decode(Int.self) {
            self.init(intValue: v)
            return
          }
          if let s = try? container.decode(String.self) {
            if let v = Int(s) {
              self.init(intValue: v)
            } else {
              self.init(stringValue: s)
            }
            return
          }
          throw DecodingError.dataCorruptedError(
            in: container, debugDescription: "Expected enum value, must be integer or string.")
        }

        public func encode(to encoder: Encoder) throws {
          var container = encoder.singleValueContainer()
          switch self {
          case .unspecified: return try container.encode(0)
          case .disabled: return try container.encode(1)
          case .enabled: return try container.encode(2)
          case .auto: return try container.encode(3)
          case .unknownIntValue(let v): return try container.encode(v)
          case .unknownStringValue(let v): return try container.encode(v)
          }
        }
      }

      public static var _anyTypeUrl: Swift.String {
        return
          "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.SearchAsYouTypeSpec"
      }
      public init(fromAny any: GoogleCloudWkt.`Any`) throws {
        self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
      }
      public func _pack() throws -> GoogleCloudWkt.Struct {
        return try GoogleCloudWkt._slowAnySerialize(message: self)
      }
    }

    /// Specifies features for display, like match highlighting.
    public struct DisplaySpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// The condition under which match highlighting should occur.
      public var matchHighlightingCondition: SearchRequest.DisplaySpec.MatchHighlightingCondition =
        SearchRequest.DisplaySpec.MatchHighlightingCondition()

      /// Initialize a new instance of `DisplaySpec`.
      public init() {}

      /// Use `config` to return a new instance of this object, with some fields updated.
      ///
      /// Commonly used to initialize the value, for example:
      ///
      /// ```
      /// let value = DisplaySpec().with { $0.matchHighlightingCondition = ... }
      /// ```
      public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
        var copy = self
        try config(&copy)
        return copy
      }

      /// Enum describing under which condition match highlighting should occur.
      public enum MatchHighlightingCondition: Codable, Equatable, Sendable {
        /// Server behavior is the same as `MATCH_HIGHLIGHTING_DISABLED`.
        case unspecified
        /// Disables match highlighting on all documents.
        case matchHighlightingDisabled
        /// Enables match highlighting on all documents.
        case matchHighlightingEnabled
        /// Encodes an unknown integer value.
        ///
        /// The most common cause for an unknown values is for the service to send
        /// a value unknown to the library. We recommend you update your library to
        /// the latest version.
        case unknownIntValue(Int)
        /// Encodes an unknown string value.
        ///
        /// The most common cause for an unknown values is for the service to send
        /// a value unknown to the library. We recommend you update your library to
        /// the latest version.
        case unknownStringValue(String)

        public init() {
          self = .unspecified
        }

        /// Returns the integer value associated with the enumeration.
        ///
        /// If the enumeration was initialized with an unknown string value, this returns `nil`.
        public var intValue: Int? {
          switch self {
          case .unspecified: return 0
          case .matchHighlightingDisabled: return 1
          case .matchHighlightingEnabled: return 2
          case .unknownIntValue(let v): return v
          case .unknownStringValue: return nil
          }
        }

        /// Returns the string value (or name) associated with the enumeration.
        ///
        /// If the enumeration was initialized with an unknown integer value, this returns `nil`.
        public var stringValue: Swift.String? {
          switch self {
          case .unspecified: return "MATCH_HIGHLIGHTING_CONDITION_UNSPECIFIED"
          case .matchHighlightingDisabled: return "MATCH_HIGHLIGHTING_DISABLED"
          case .matchHighlightingEnabled: return "MATCH_HIGHLIGHTING_ENABLED"
          case .unknownIntValue: return nil
          case .unknownStringValue(let v): return v
          }
        }

        /// Initialize from a string value.
        ///
        /// If the value is unknown, this initializes to [`unknownStringValue`](doc:MatchHighlightingCondition/unknownStringValue(_:)).
        public init(stringValue: Swift.String) {
          switch stringValue {
          case "MATCH_HIGHLIGHTING_CONDITION_UNSPECIFIED": self = .unspecified
          case "MATCH_HIGHLIGHTING_DISABLED": self = .matchHighlightingDisabled
          case "MATCH_HIGHLIGHTING_ENABLED": self = .matchHighlightingEnabled
          default: self = .unknownStringValue(stringValue)
          }
        }

        /// Initialize from an integer value.
        ///
        /// If the value is unknown, this initializes to [`unknownIntValue`](doc:MatchHighlightingCondition/unknownIntValue(_:)).
        public init(intValue: Int) {
          switch intValue {
          case 0: self = .unspecified
          case 1: self = .matchHighlightingDisabled
          case 2: self = .matchHighlightingEnabled
          default: self = .unknownIntValue(intValue)
          }
        }

        public init(from decoder: Decoder) throws {
          let container = try decoder.singleValueContainer()
          if let v = try? container.decode(Int.self) {
            self.init(intValue: v)
            return
          }
          if let s = try? container.decode(String.self) {
            if let v = Int(s) {
              self.init(intValue: v)
            } else {
              self.init(stringValue: s)
            }
            return
          }
          throw DecodingError.dataCorruptedError(
            in: container, debugDescription: "Expected enum value, must be integer or string.")
        }

        public func encode(to encoder: Encoder) throws {
          var container = encoder.singleValueContainer()
          switch self {
          case .unspecified: return try container.encode(0)
          case .matchHighlightingDisabled: return try container.encode(1)
          case .matchHighlightingEnabled: return try container.encode(2)
          case .unknownIntValue(let v): return try container.encode(v)
          case .unknownStringValue(let v): return try container.encode(v)
          }
        }
      }

      public static var _anyTypeUrl: Swift.String {
        return "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.DisplaySpec"
      }
      public init(fromAny any: GoogleCloudWkt.`Any`) throws {
        self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
      }
      public func _pack() throws -> GoogleCloudWkt.Struct {
        return try GoogleCloudWkt._slowAnySerialize(message: self)
      }
    }

    /// Specification for crowding. Crowding improves the diversity of search
    /// results by limiting the number of results that share the same field value.
    /// For example, crowding on the color field with a max_count of 3 and mode
    /// DROP_CROWDED_RESULTS will return at most 3 results with the same color
    /// across all pages.
    public struct CrowdingSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// The field to use for crowding. Documents can be crowded by a field in the
      /// [Document][google.cloud.discoveryengine.v1.Document] object. Crowding
      /// field is case sensitive.
      ///
      /// [google.cloud.discoveryengine.v1.Document]: <doc:Document>
      public var field: Swift.String = Swift.String()

      /// The maximum number of documents to keep per value of the field. Once
      /// there are at least max_count previous results which contain the same
      /// value for the given field (according to the order specified in
      /// `order_by`), later results with the same value are "crowded away".
      /// If not specified, the default value is 1.
      public var maxCount: Swift.Int32 = Swift.Int32()

      /// Mode to use for documents that are crowded away.
      public var mode: SearchRequest.CrowdingSpec.Mode = SearchRequest.CrowdingSpec.Mode()

      /// Initialize a new instance of `CrowdingSpec`.
      public init() {}

      /// Use `config` to return a new instance of this object, with some fields updated.
      ///
      /// Commonly used to initialize the value, for example:
      ///
      /// ```
      /// let value = CrowdingSpec().with { $0.field = ... }
      /// ```
      public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
        var copy = self
        try config(&copy)
        return copy
      }

      /// Enum describing the mode to use for documents that are crowded away.
      /// They can be dropped or demoted to the later pages.
      public enum Mode: Codable, Equatable, Sendable {
        /// Unspecified crowding mode. In this case, server behavior defaults to
        /// [Mode.DROP_CROWDED_RESULTS][google.cloud.discoveryengine.v1.SearchRequest.CrowdingSpec.Mode.DROP_CROWDED_RESULTS].
        ///
        /// [google.cloud.discoveryengine.v1.SearchRequest.CrowdingSpec.Mode.DROP_CROWDED_RESULTS]: <doc:SearchRequest/CrowdingSpec/Mode/dropCrowdedResults>
        case unspecified
        /// Drop crowded results.
        case dropCrowdedResults
        /// Demote crowded results to the later pages.
        case demoteCrowdedResultsToEnd
        /// Encodes an unknown integer value.
        ///
        /// The most common cause for an unknown values is for the service to send
        /// a value unknown to the library. We recommend you update your library to
        /// the latest version.
        case unknownIntValue(Int)
        /// Encodes an unknown string value.
        ///
        /// The most common cause for an unknown values is for the service to send
        /// a value unknown to the library. We recommend you update your library to
        /// the latest version.
        case unknownStringValue(String)

        public init() {
          self = .unspecified
        }

        /// Returns the integer value associated with the enumeration.
        ///
        /// If the enumeration was initialized with an unknown string value, this returns `nil`.
        public var intValue: Int? {
          switch self {
          case .unspecified: return 0
          case .dropCrowdedResults: return 1
          case .demoteCrowdedResultsToEnd: return 2
          case .unknownIntValue(let v): return v
          case .unknownStringValue: return nil
          }
        }

        /// Returns the string value (or name) associated with the enumeration.
        ///
        /// If the enumeration was initialized with an unknown integer value, this returns `nil`.
        public var stringValue: Swift.String? {
          switch self {
          case .unspecified: return "MODE_UNSPECIFIED"
          case .dropCrowdedResults: return "DROP_CROWDED_RESULTS"
          case .demoteCrowdedResultsToEnd: return "DEMOTE_CROWDED_RESULTS_TO_END"
          case .unknownIntValue: return nil
          case .unknownStringValue(let v): return v
          }
        }

        /// Initialize from a string value.
        ///
        /// If the value is unknown, this initializes to [`unknownStringValue`](doc:Mode/unknownStringValue(_:)).
        public init(stringValue: Swift.String) {
          switch stringValue {
          case "MODE_UNSPECIFIED": self = .unspecified
          case "DROP_CROWDED_RESULTS": self = .dropCrowdedResults
          case "DEMOTE_CROWDED_RESULTS_TO_END": self = .demoteCrowdedResultsToEnd
          default: self = .unknownStringValue(stringValue)
          }
        }

        /// Initialize from an integer value.
        ///
        /// If the value is unknown, this initializes to [`unknownIntValue`](doc:Mode/unknownIntValue(_:)).
        public init(intValue: Int) {
          switch intValue {
          case 0: self = .unspecified
          case 1: self = .dropCrowdedResults
          case 2: self = .demoteCrowdedResultsToEnd
          default: self = .unknownIntValue(intValue)
          }
        }

        public init(from decoder: Decoder) throws {
          let container = try decoder.singleValueContainer()
          if let v = try? container.decode(Int.self) {
            self.init(intValue: v)
            return
          }
          if let s = try? container.decode(String.self) {
            if let v = Int(s) {
              self.init(intValue: v)
            } else {
              self.init(stringValue: s)
            }
            return
          }
          throw DecodingError.dataCorruptedError(
            in: container, debugDescription: "Expected enum value, must be integer or string.")
        }

        public func encode(to encoder: Encoder) throws {
          var container = encoder.singleValueContainer()
          switch self {
          case .unspecified: return try container.encode(0)
          case .dropCrowdedResults: return try container.encode(1)
          case .demoteCrowdedResultsToEnd: return try container.encode(2)
          case .unknownIntValue(let v): return try container.encode(v)
          case .unknownStringValue(let v): return try container.encode(v)
          }
        }
      }

      public static var _anyTypeUrl: Swift.String {
        return "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.CrowdingSpec"
      }
      public init(fromAny any: GoogleCloudWkt.`Any`) throws {
        self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
      }
      public func _pack() throws -> GoogleCloudWkt.Struct {
        return try GoogleCloudWkt._slowAnySerialize(message: self)
      }
    }

    /// Session specification.
    ///
    /// Multi-turn Search feature is currently at private GA stage. Please use
    /// v1alpha or v1beta version instead before we launch this feature to public
    /// GA. Or ask for allowlisting through Google Support team.
    public struct SessionSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// If set, the search result gets stored to the "turn" specified by this
      /// query ID.
      ///
      /// Example: Let's say the session looks like this:
      ///   session {
      ///     name: ".../sessions/xxx"
      ///     turns {
      ///       query { text: "What is foo?" query_id: ".../questions/yyy" }
      ///       answer: "Foo is ..."
      ///     }
      ///     turns {
      ///       query { text: "How about bar then?" query_id: ".../questions/zzz" }
      ///     }
      ///   }
      ///
      /// The user can call /search API with a request like this:
      ///
      ///    session: ".../sessions/xxx"
      ///    session_spec { query_id: ".../questions/zzz" }
      ///
      /// Then, the API stores the search result, associated with the last turn.
      /// The stored search result can be used by a subsequent /answer API call
      /// (with the session ID and the query ID specified). Also, it is possible
      /// to call /search and /answer in parallel with the same session ID & query
      /// ID.
      public var queryId: Swift.String = Swift.String()

      /// The number of top search results to persist. The persisted search results
      /// can be used for the subsequent /answer api call.
      ///
      /// This field is similar to the `summary_result_count` field in
      /// [SearchRequest.ContentSearchSpec.SummarySpec.summary_result_count][google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec.SummarySpec.summary_result_count].
      ///
      /// At most 10 results for documents mode, or 50 for chunks mode.
      ///
      /// [google.cloud.discoveryengine.v1.SearchRequest.ContentSearchSpec.SummarySpec.summary_result_count]: <doc:SearchRequest/ContentSearchSpec/SummarySpec/summaryResultCount>
      public var searchResultPersistenceCount: Swift.Int32? = nil

      /// Initialize a new instance of `SessionSpec`.
      public init() {}

      /// Use `config` to return a new instance of this object, with some fields updated.
      ///
      /// Commonly used to initialize the value, for example:
      ///
      /// ```
      /// let value = SessionSpec().with { $0.queryId = ... }
      /// ```
      public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
        var copy = self
        try config(&copy)
        return copy
      }

      public static var _anyTypeUrl: Swift.String {
        return "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.SessionSpec"
      }
      public init(fromAny any: GoogleCloudWkt.`Any`) throws {
        self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
      }
      public func _pack() throws -> GoogleCloudWkt.Struct {
        return try GoogleCloudWkt._slowAnySerialize(message: self)
      }
    }

    /// The specification for returning the document relevance score.
    public struct RelevanceScoreSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Optional. Whether to return the relevance score for search results.
      /// The higher the score, the more relevant the document is to the query.
      public var returnRelevanceScore: Swift.Bool = Swift.Bool()

      /// Initialize a new instance of `RelevanceScoreSpec`.
      public init() {}

      /// Use `config` to return a new instance of this object, with some fields updated.
      ///
      /// Commonly used to initialize the value, for example:
      ///
      /// ```
      /// let value = RelevanceScoreSpec().with { $0.returnRelevanceScore = ... }
      /// ```
      public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
        var copy = self
        try config(&copy)
        return copy
      }

      public static var _anyTypeUrl: Swift.String {
        return
          "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.RelevanceScoreSpec"
      }
      public init(fromAny any: GoogleCloudWkt.`Any`) throws {
        self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
      }
      public func _pack() throws -> GoogleCloudWkt.Struct {
        return try GoogleCloudWkt._slowAnySerialize(message: self)
      }
    }

    /// Relevance filtering specification.
    public struct RelevanceFilterSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
      Sendable
    {
      /// Optional. Relevance filtering threshold specification for keyword search.
      public var keywordSearchThreshold: SearchRequest.RelevanceFilterSpec.RelevanceThresholdSpec? =
        nil

      /// Optional. Relevance filtering threshold specification for semantic
      /// search.
      public var semanticSearchThreshold:
        SearchRequest.RelevanceFilterSpec.RelevanceThresholdSpec? = nil

      /// Initialize a new instance of `RelevanceFilterSpec`.
      public init() {}

      /// Use `config` to return a new instance of this object, with some fields updated.
      ///
      /// Commonly used to initialize the value, for example:
      ///
      /// ```
      /// let value = RelevanceFilterSpec().with { $0.keywordSearchThreshold = ... }
      /// ```
      public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
        var copy = self
        try config(&copy)
        return copy
      }

      /// Specification for relevance filtering on a specific sub-search.
      public struct RelevanceThresholdSpec: Codable, Equatable, GoogleCloudWkt._AnyPackable,
        Sendable
      {
        /// Configures how the relevance threshold is determined.
        public var relevanceThresholdSpec: OneOf_RelevanceThresholdSpec? = nil

        /// Initialize a new instance of `RelevanceThresholdSpec`.
        public init() {}

        /// Use `config` to return a new instance of this object, with some fields updated.
        ///
        /// Commonly used to initialize the value, for example:
        ///
        /// ```
        /// let value = RelevanceThresholdSpec().with { $0.relevanceThreshold = ... }
        /// ```
        public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
          var copy = self
          try config(&copy)
          return copy
        }

        private enum CodingKeys: Swift.String, CodingKey {
          case relevanceThreshold = "relevanceThreshold"
          case semanticRelevanceThreshold = "semanticRelevanceThreshold"
        }

        public init(from decoder: Decoder) throws {
          let container = try decoder.container(keyedBy: CodingKeys.self)

          var relevanceThresholdSpec: OneOf_RelevanceThresholdSpec? = nil
          let relevanceThresholdSpecCheckAndSet = {
            if relevanceThresholdSpec != nil {
              throw DecodingError.dataCorrupted(
                DecodingError.Context(
                  codingPath: decoder.codingPath,
                  debugDescription: "Multiple values set for oneof 'relevanceThresholdSpec'"))
            }
            relevanceThresholdSpec = $0
          }
          if let relevanceThreshold = try container.decodeIfPresent(
            SearchRequest.RelevanceThreshold.self, forKey: .relevanceThreshold)
          {
            try relevanceThresholdSpecCheckAndSet(.relevanceThreshold(relevanceThreshold))
          }
          if let semanticRelevanceThreshold = try container.decodeIfPresent(
            Swift.Float.self, forKey: .semanticRelevanceThreshold)
          {
            try relevanceThresholdSpecCheckAndSet(
              .semanticRelevanceThreshold(semanticRelevanceThreshold))
          }
          self.relevanceThresholdSpec = relevanceThresholdSpec
        }

        public func encode(to encoder: Encoder) throws {
          var container = encoder.container(keyedBy: CodingKeys.self)

          if let choice = self.relevanceThresholdSpec {
            switch choice {
            case .relevanceThreshold(let value):
              try container.encode(value, forKey: .relevanceThreshold)
            case .semanticRelevanceThreshold(let value):
              try container.encode(value, forKey: .semanticRelevanceThreshold)
            }
          }
        }

        /// Configures how the relevance threshold is determined.
        public enum OneOf_RelevanceThresholdSpec: Codable, Equatable, Sendable {
          /// Pre-defined relevance threshold for the sub-search.
          case relevanceThreshold(SearchRequest.RelevanceThreshold)
          /// Custom relevance threshold for the sub-search.
          /// The value must be in [0.0, 1.0].
          case semanticRelevanceThreshold(Swift.Float)
        }

        public static var _anyTypeUrl: Swift.String {
          return
            "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.RelevanceFilterSpec.RelevanceThresholdSpec"
        }
        public init(fromAny any: GoogleCloudWkt.`Any`) throws {
          self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
        }
        public func _pack() throws -> GoogleCloudWkt.Struct {
          return try GoogleCloudWkt._slowAnySerialize(message: self)
        }
      }

      public static var _anyTypeUrl: Swift.String {
        return
          "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest.RelevanceFilterSpec"
      }
      public init(fromAny any: GoogleCloudWkt.`Any`) throws {
        self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
      }
      public func _pack() throws -> GoogleCloudWkt.Struct {
        return try GoogleCloudWkt._slowAnySerialize(message: self)
      }
    }

    /// The backend to use for the ranking expression evaluation.
    public enum RankingExpressionBackend: Codable, Equatable, Sendable {
      /// Default option for unspecified/unknown values.
      case unspecified
      /// Deprecated: Use `RANK_BY_EMBEDDING` instead.
      /// Ranking by custom embedding model, the default way to evaluate the
      /// ranking expression. Legacy enum option, `RANK_BY_EMBEDDING` should be
      /// used instead.
      @available(*, deprecated)
      case byoe
      /// Deprecated: Use `RANK_BY_FORMULA` instead.
      /// Ranking by custom formula. Legacy enum option, `RANK_BY_FORMULA` should
      /// be used instead.
      @available(*, deprecated)
      case clearbox
      /// Ranking by custom embedding model, the default way to evaluate the
      /// ranking expression.
      case rankByEmbedding
      /// Ranking by custom formula.
      case rankByFormula
      /// Encodes an unknown integer value.
      ///
      /// The most common cause for an unknown values is for the service to send
      /// a value unknown to the library. We recommend you update your library to
      /// the latest version.
      case unknownIntValue(Int)
      /// Encodes an unknown string value.
      ///
      /// The most common cause for an unknown values is for the service to send
      /// a value unknown to the library. We recommend you update your library to
      /// the latest version.
      case unknownStringValue(String)

      public init() {
        self = .unspecified
      }

      /// Returns the integer value associated with the enumeration.
      ///
      /// If the enumeration was initialized with an unknown string value, this returns `nil`.
      public var intValue: Int? {
        switch self {
        case .unspecified: return 0
        case .byoe: return 1
        case .clearbox: return 2
        case .rankByEmbedding: return 3
        case .rankByFormula: return 4
        case .unknownIntValue(let v): return v
        case .unknownStringValue: return nil
        }
      }

      /// Returns the string value (or name) associated with the enumeration.
      ///
      /// If the enumeration was initialized with an unknown integer value, this returns `nil`.
      public var stringValue: Swift.String? {
        switch self {
        case .unspecified: return "RANKING_EXPRESSION_BACKEND_UNSPECIFIED"
        case .byoe: return "BYOE"
        case .clearbox: return "CLEARBOX"
        case .rankByEmbedding: return "RANK_BY_EMBEDDING"
        case .rankByFormula: return "RANK_BY_FORMULA"
        case .unknownIntValue: return nil
        case .unknownStringValue(let v): return v
        }
      }

      /// Initialize from a string value.
      ///
      /// If the value is unknown, this initializes to [`unknownStringValue`](doc:RankingExpressionBackend/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "RANKING_EXPRESSION_BACKEND_UNSPECIFIED": self = .unspecified
        case "BYOE": self = .byoe
        case "CLEARBOX": self = .clearbox
        case "RANK_BY_EMBEDDING": self = .rankByEmbedding
        case "RANK_BY_FORMULA": self = .rankByFormula
        default: self = .unknownStringValue(stringValue)
        }
      }

      /// Initialize from an integer value.
      ///
      /// If the value is unknown, this initializes to [`unknownIntValue`](doc:RankingExpressionBackend/unknownIntValue(_:)).
      public init(intValue: Int) {
        switch intValue {
        case 0: self = .unspecified
        case 1: self = .byoe
        case 2: self = .clearbox
        case 3: self = .rankByEmbedding
        case 4: self = .rankByFormula
        default: self = .unknownIntValue(intValue)
        }
      }

      public init(from decoder: Decoder) throws {
        let container = try decoder.singleValueContainer()
        if let v = try? container.decode(Int.self) {
          self.init(intValue: v)
          return
        }
        if let s = try? container.decode(String.self) {
          if let v = Int(s) {
            self.init(intValue: v)
          } else {
            self.init(stringValue: s)
          }
          return
        }
        throw DecodingError.dataCorruptedError(
          in: container, debugDescription: "Expected enum value, must be integer or string.")
      }

      public func encode(to encoder: Encoder) throws {
        var container = encoder.singleValueContainer()
        switch self {
        case .unspecified: return try container.encode(0)
        case .byoe: return try container.encode(1)
        case .clearbox: return try container.encode(2)
        case .rankByEmbedding: return try container.encode(3)
        case .rankByFormula: return try container.encode(4)
        case .unknownIntValue(let v): return try container.encode(v)
        case .unknownStringValue(let v): return try container.encode(v)
        }
      }
    }

    /// The relevance threshold of the search results. The higher relevance
    /// threshold is, the higher relevant results are shown and the less number of
    /// results are returned.
    public enum RelevanceThreshold: Codable, Equatable, Sendable {
      /// Default value. In this case, server behavior defaults to Google defined
      /// threshold.
      case unspecified
      /// Lowest relevance threshold.
      case lowest
      /// Low relevance threshold.
      case low
      /// Medium relevance threshold.
      case medium
      /// High relevance threshold.
      case high
      /// Encodes an unknown integer value.
      ///
      /// The most common cause for an unknown values is for the service to send
      /// a value unknown to the library. We recommend you update your library to
      /// the latest version.
      case unknownIntValue(Int)
      /// Encodes an unknown string value.
      ///
      /// The most common cause for an unknown values is for the service to send
      /// a value unknown to the library. We recommend you update your library to
      /// the latest version.
      case unknownStringValue(String)

      public init() {
        self = .unspecified
      }

      /// Returns the integer value associated with the enumeration.
      ///
      /// If the enumeration was initialized with an unknown string value, this returns `nil`.
      public var intValue: Int? {
        switch self {
        case .unspecified: return 0
        case .lowest: return 1
        case .low: return 2
        case .medium: return 3
        case .high: return 4
        case .unknownIntValue(let v): return v
        case .unknownStringValue: return nil
        }
      }

      /// Returns the string value (or name) associated with the enumeration.
      ///
      /// If the enumeration was initialized with an unknown integer value, this returns `nil`.
      public var stringValue: Swift.String? {
        switch self {
        case .unspecified: return "RELEVANCE_THRESHOLD_UNSPECIFIED"
        case .lowest: return "LOWEST"
        case .low: return "LOW"
        case .medium: return "MEDIUM"
        case .high: return "HIGH"
        case .unknownIntValue: return nil
        case .unknownStringValue(let v): return v
        }
      }

      /// Initialize from a string value.
      ///
      /// If the value is unknown, this initializes to [`unknownStringValue`](doc:RelevanceThreshold/unknownStringValue(_:)).
      public init(stringValue: Swift.String) {
        switch stringValue {
        case "RELEVANCE_THRESHOLD_UNSPECIFIED": self = .unspecified
        case "LOWEST": self = .lowest
        case "LOW": self = .low
        case "MEDIUM": self = .medium
        case "HIGH": self = .high
        default: self = .unknownStringValue(stringValue)
        }
      }

      /// Initialize from an integer value.
      ///
      /// If the value is unknown, this initializes to [`unknownIntValue`](doc:RelevanceThreshold/unknownIntValue(_:)).
      public init(intValue: Int) {
        switch intValue {
        case 0: self = .unspecified
        case 1: self = .lowest
        case 2: self = .low
        case 3: self = .medium
        case 4: self = .high
        default: self = .unknownIntValue(intValue)
        }
      }

      public init(from decoder: Decoder) throws {
        let container = try decoder.singleValueContainer()
        if let v = try? container.decode(Int.self) {
          self.init(intValue: v)
          return
        }
        if let s = try? container.decode(String.self) {
          if let v = Int(s) {
            self.init(intValue: v)
          } else {
            self.init(stringValue: s)
          }
          return
        }
        throw DecodingError.dataCorruptedError(
          in: container, debugDescription: "Expected enum value, must be integer or string.")
      }

      public func encode(to encoder: Encoder) throws {
        var container = encoder.singleValueContainer()
        switch self {
        case .unspecified: return try container.encode(0)
        case .lowest: return try container.encode(1)
        case .low: return try container.encode(2)
        case .medium: return try container.encode(3)
        case .high: return try container.encode(4)
        case .unknownIntValue(let v): return try container.encode(v)
        case .unknownStringValue(let v): return try container.encode(v)
        }
      }
    }

    public static var _anyTypeUrl: Swift.String {
      return "type.googleapis.com/google.cloud.discoveryengine.v1.SearchRequest"
    }
    public init(fromAny any: GoogleCloudWkt.`Any`) throws {
      self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
    }
    public func _pack() throws -> GoogleCloudWkt.Struct {
      return try GoogleCloudWkt._slowAnySerialize(message: self)
    }
  }
#endif
