# Copyright 2021 - 2025 PeopleWare n.v.
#
# 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
#
#     http://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.

type: object
examples:
  - structureVersion: 1
    exact:
      - '0123456789'
      - '9876543210'
    fuzzy:
      - find me
      - if you can
      - '9876543210'
    content:
      structureVersion: 1
      discriminator: service-name/type-name
      href: /service-name/service_version/type-name/type_unique_identifier?at=2021-01-19T17:14:18.482Z
description: >-
  Wrapper around the search result (which is returned to the client when the resource is found), with information for a
  search index.


  It contains strings for which the resource this is a search document for can be found by, and the `content` that is to
  be sent to the client. The resource this is a search document for can be found with an exact match on the strings in
  `exact`, and by a fuzzy search on the strings in `fuzzy`. Some strings might appear in both.


  `fuzzy` or `exact` may be empty, but not both.


  Search results can be limited to selected types with an exact match on `content.discriminator`. The found resource can
  be retrieved in the indexed version at `content.href`.
properties:
  structureVersion:
    type: integer
    examples:
      - 1
    description: Version of the data structure of this resource type
    minimum: 1
  exact:
    type: array
    examples:
      - - '0123456789'
        - '9876543210'
    description: >-
      List of strings on which the resource can be found with exact match.


      The order is irrelevant. May be empty if `fuzzy` is not empty.
    uniqueItems: true
    items:
      type: string
      examples:
        - Mari
        - Jos
        - '0123456789'
        - '0123456789'
      description: free text on which the resource can be found (trimmed, not empty)
      minLength: 1
  fuzzy:
    type: array
    examples:
      - - find me
        - if you can
    description: >-
      List of strings on which the resource can be found with fuzzy match.


      The order is irrelevant. May be empty if `exact` is not empty.
    uniqueItems: true
    items:
      type: string
      examples:
        - Mari
        - Jos
        - '0123456789'
      description: free text on which the resource can be found (trimmed, not empty)
      minLength: 1
    minItems: 1
  content:
    type: object
    examples:
      - structureVersion: 1
        discriminator: service-name/type-name
        href: /service-name/service_version/type-name/type_unique_identifier?at=2021-01-19T17:14:18.482Z
    description: The resource's search document with the most up-to-date information, i.e., up-to-date up until, but not
      including, `x-date`.
    properties:
      structureVersion:
        type: integer
        examples:
          - 1
        description: Version of the data structure of this resource type
        minimum: 1
      href:
        type: string
        examples:
          - ../some/path
          - some/other/path
          - ./meaningless/dot
        description: >-
          Relative URI where the found resource's information is located. The `at` parameter _must_ be the same as the
          value of the `x-date` response header.


          Users need to be directed to the version returned by the search index, and not an earlier or more recent
          version. The search engine updates, eventually, after a few seconds. If a more recent version is available in
          the meantime, the user interface makes it possible for the user to navigate to that version.
        format: uri-reference
        minLength: 1
      discriminator:
        type: string
        examples:
          - service-name/type-name
        description: >-
          Type of the indexed resource.


          This enables users to search only on particular resource type. The type is qualified with the service name, to
          avoid name clashes (slash-separated).
        minLength: 1
        pattern: ^([-a-z0-9]+)\/([-a-z0-9/]+)$
    required:
      - structureVersion
      - href
      - discriminator
    additionalProperties: true
    deprecated: true
required:
  - structureVersion
  - exact
  - fuzzy
  - content
additionalProperties: true
deprecated: true
