summaryrefslogtreecommitdiffstats
path: root/toolkit/components/search/docs/SearchConfigurationSchema.rst
blob: ceeaa5cb5795fbdbe860352e58566fe84acbe8a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
===========================
Search Configuration Schema
===========================

This document outlines the details of the `search-config-v2`_ schema and how
the various sub-parts interact. For the full fields and descriptions, please see
the `schema itself`_.

.. note::
    In the examples, only relevant properties are displayed.

Overview
========

The configuration is a JSON blob, an object with a ``data`` property and value
as an array containing ``engine``, ``defaultEngines``, and ``engineOrders``
record types:

.. code-block:: js

    {
      data: [
        {
          // defaultEngines details
        },
        {
          // engine 1 details
        },
        {
          // engine 2 details
        },
        {
          // engineOrders details
        },
      ]
    }

Environment
===========
An ``environment`` property is contained within each of the record types and is
used to determine where some, or all, of that record is applied to according to
the user's detected environment. There are many different properties in ``environment``.
These may be used individually or together to build up a match. Here is the list
of those properties:

``allRegionsAndLocales``
  - ``"environment": { "allRegionsAndLocales": true }``
  - Indicates that this section applies to all regions and locales. May be
    modified by excludedRegions/excludedLocales.

``applications``
  - ``"environment": { "applications": ["firefox"] }``
  - This property specifies the applications the record would be applied to.
  - Some applications we support are ``firefox``, ``firefox-android``, ``firefox-ios``,
    ``focus-android``, and ``focus-ios``.

``channels``
  - ``"environment": { "channels": ["default"] }``
  - One or more channels may be specified in an array to restrict a configuration
    to just those channels. The following is a list of the channels:

    - default: Self-builds of Firefox, or possibly some self-distributed versions.
    - nightly: Firefox Nightly builds.
    - aurora: Firefox Developer Edition.
    - beta: Firefox Beta.
    - release: The main Firefox release channel.
    - esr: The ESR Channel. This will also match versions of Firefox where the
      displayed version number includes ``esr``. We do this to include Linux
      distributions and other manual builds of ESR.

``distributions``
  - ``"environment": { "distributions": ["distribution-name"] }``
  - An array of distribution identifiers that the record object applies to.
  - The identifiers match those supplied by the ``distribution.id`` preference.

``excludedDistributions``
  - ``"environment": { "distributions": ["distribution-excluded"] }``
  - An array of distribution identifiers that the record object does not apply to.

``excludedLocales``
  - ``"environment": { "excludedLocales": ["de"] }``
  - An array of locales that this section should be excluded from.

``excludedRegions``
  - ``"environment": { "excludedRegions": ["ca"] }``
  - An array of regions that this section should be excluded from.

``experiment``
  - ``"environment": { "experiment": "experimental" }``
  - Experiments can be run by giving a value to the ``experiment`` property.
  - The experiment value should also be supplied to the ``experiment`` property
    of the ``searchConfiguration`` feature on Nimbus.

``locales``
  - ``"environment": { "locales": ["en-US"] }``
  - An array of locales that this section applies to.

``regions``
  - ``"environment": { "regions": ["ca"] }``
  - An array of regions that this section applies to.
  - ``"unknown"`` may be used to apply to situations where we have not been able
    to detect the user's region. However, this is not currently expected to be used.

``maxVersion`` and ``minVersion``
  - Minimum and Maximum versions may be specified to restrict a configuration to
    specific ranges. These may be open-ended. Version comparison is performed
    using `the version comparator`_.
  - Note: comparison against ``maxVersion`` is a less-than comparison. The
    ``maxVersion`` won't be matched directly.
  - ``"environment": { "minVersion": "72.0a1" }`` Indicates the record object
    will be included for any version after 72.0a1.
  - ``"environment": { "minVersion": "68.0a1", "maxVersion": "72.0a1" }``
    Indicates the record object would be included only between 68.0a1 and 71.x
    version.

Engine Objects
==============

Each engine object represents a search engine that may be presented to a user.
Each engine object is treated as a separate engine within the application, with
independent settings.

.. code-block:: js

    {
      "base": {
        "classification": "general"
        "name": "engine1 name",
        "partnerCode": "bar",
        "urls": {
          "search": {
            "base": "https://www.example.com",
            "params": [
              {
                "name": "code",
                "value": "{partnerCode}"
              }
            ],
            "searchTermParamName": "q"
          },
        },
      },
      "identifier": "engine1",
      "recordType": "engine",
      "variants": [
        {
          "environment": { "allRegionsAndLocales": true }
        }
      ]
    }

The required **top-level** properties are:

- ``base`` Defines the base details for the engine. The required base properties
  are ``classification``, ``name``, and ``urls``.

    - The ``urls`` may be different types of  urls. These various types include
      ``search``, ``suggestions``, and ``trending`` urls. The url property contains
      the base url and any query string params to build the complete url. If
      ``engine1`` is used to search ``kitten``, the search url will be constructed
      as ``https://www.example.com/?code=bar&q=kitten``. Notice the ``partnerCode``
      from the base is inserted into parameters ``{partnerCode}`` value of the search url.
- ``identifier`` Identifies the search engine and is used internally to set the telemetry id.
- ``recordType`` The type of record the object is. Always ``engine`` for engine
  objects.
- ``variants`` Specifies the environment the engine is included in, which details
  the region, locale, and other environment properties.

Engine Variants
===============
A engine may be available only to users located in specific regions or with
certain locales. For example, when the ``environment`` section of variants specify
locales and regions:

.. code-block:: js

    "variants": [
      {
        "environment": { "locales": ["en-US"], "regions": ["US"] }
      }
    ]

In this case users identified as being in the ``en-US`` locale and ``US`` region
would be able to have the engine available.

**Multiple Variants**

When there are more than one variant the last matching variant will be applied.

.. code-block:: js

  "variants": [
    {
      "environment": { "locales": ["en-US"] }
      "partnerCode": "bar"
    },
    {
      "environment": { "locales": ["en-US"], "regions": ["US"]}
      "partnerCode": "foo"
    },
  ]

In this case users identified in ``en-US`` locale and ``US`` region  matched
both the variants. Users in ``en-US`` locale and ``US`` region matched the
first variant because it has ``en-US`` locales and when regions is not specified,
it means all regions are included. Then it matched the second variant because it matched
``en-US`` locale and ``US`` region. The result will be that for this user the
partner code will have value ``foo``.

Engine Subvariants
==================
Nested within ``variants`` may be an array of ``subVariants``. Subvariants
contain the same properties as variants except the ``subVariants`` property. The
purpose of subvariants is for the combination of environment properties from the
last matched subvariant and the top level variant.

.. code-block:: js

    "variants": [
      {
        "environment": { "regions": ["US", "CA", "GB"] }
        "subVariants": [
          {
            "environment": { "channels": [ "esr"] },
            "partnerCode": "bar",
          },
        ]
      }
    ]

In this case users identified as being in ``US`` region and ``esr`` channel
would match the subvariant and would be able to have the engine available with
partner code ``bar`` applied.

**Multiple Subvariants**

When there are more than one subvariant the last matching subvariant will be
applied.

.. code-block:: js

  "variants": [
    {
      "environment": { "regions": ["US", "CA", "GB"] }
      "subVariants": [
        {
          "environment": { "channels": [ "esr"] },
          "partnerCode": "bar",
        },
        {
          "environment": { "channels": [ "esr"], "locales": ["fr"] },
          "partnerCode": "foo",
        }
      ]
    }
  ]

In this case users identified in ``US`` region, ``fr`` locale, and ``esr`` channel
matched both the subvariants. It matched the first subvariant because the first
environment has ``US`` region from the top-level variant, ``esr`` channel, and
all locales. Then it matched the second variant because the second environment
has ``US`` region from top-level variant, ``fr`` locale, and ``esr`` channel.
The user will receive the last matched subvariant with partner code ``foo``.

Engine Defaults
===============

An engine may be specified as the default for one of two purposes:

#. normal browsing mode,
#. private browsing mode.

If there is no engine specified for private browsing mode for a particular region/locale
pair, then the normal mode engine is used.

If the instance of the application does not support a separate private browsing mode engine,
then it will only use the normal mode engine.

An engine may or may not be default for particular regions/locales. The
``defaultEngines`` record is structured to provide ``globalDefault`` and
``globalDefaultPrivate`` properties, these properties define the user's engine
if there are no ``specificDefaults`` sections that match the user's environment.
The ``specificDefaults`` sections can define different engines that match with
specific user environments.

.. code-block:: js

    {
      "globalDefault": "engine1",
      "globalDefaultPrivate": "engine1",
      "recordType": "defaultEngines",
      "specificDefaults": [
        {
          "default": "engine2",
          "defaultPrivate": "engine3"
          "environment": {
            "locales": [
              "en-CA"
            ],
            "regions": [
              "CA"
            ]
          },
        }
      ]
    }


In normal mode:

    - engine1 is default for all regions except for region CA locale en-CA
    - engine2 is default in only the CA region and locale en-CA

In private browsing mode:

    - engine1 is private default for all regions except for region CA locale en-CA
    - engine3 is private default in only the CA region and locale en-CA

Engine Ordering
===============

The ``engineOrders`` record type indicates the suggested ordering of an engine
relative to other engines when displayed to the user, unless the user has
customized their ordering. The ordering is listed in the ``order`` property, an
ordered array with the first engine being at the lowest index.

If there is no matching order for the user's environment, then this order applies:

#. Default Engine
#. Default Private Engine (if any)
#. Other engines in alphabetical order.

Example:

.. code-block:: js

    {
      "orders": [
        {
          "environment": {
            "distributions": [
              "distro"
            ]
          },
          "order": [
            "c-engine",
            "b-engine",
            "a-engine",
          ]
        }
      ]
      "recordType": "engineOrders",
    }

This would result in the order: ``c-engine``, ``b-engine``, ``a-engine`` for the
distribution ``distro``.

.. _schema itself: https://searchfox.org/mozilla-central/source/toolkit/components/search/schema/
.. _the version comparator: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/version/format
.. _search-config-v2: https://searchfox.org/mozilla-central/source/services/settings/dumps/main/search-config-v2.json