{
  "$comment": "https://www.mongodb.com/docs/atlas/atlas-search/index-definitions/#std-label-ref-index-definitions",
  "$id": "https://json.schemastore.org/mongodb-atlas-search-index-definition.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "additionalProperties": false,
  "definitions": {
    "CustomAnalyzer": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^(?!^lucene\\.|builtin\\.|mongodb\\.).*",
          "description": "Name of the custom analyzer.\nNames must be unique within an index, and may not start with any of the following strings:\n- lucene.\n- builtin.\n- mongodb."
        },
        "charFilters": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/CharFilter"
          },
          "description": "Array containing zero or more character filters."
        },
        "tokenizer": {
          "$ref": "#/definitions/Tokenizer"
        },
        "tokenFilters": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/TokenFilter"
          },
          "description": "Array containing zero or more token filters."
        }
      },
      "required": ["name", "tokenizer"],
      "title": "Analyzer"
    },
    "Tokenizer": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "edgeGram",
            "keyword",
            "nGram",
            "regexCaptureGroup",
            "regexSplit",
            "standard",
            "uaxUrlEmail",
            "whitespace"
          ]
        }
      },
      "required": ["type"],
      "title": "Tokenizer",
      "description": "Tokenizer to use to create tokens."
    },
    "TokenFilter": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "asciiFolding",
            "daitchMokotoffSoundex",
            "edgeGram",
            "icuFolding",
            "icuNormalizer",
            "length",
            "lowercase",
            "nGram",
            "regex",
            "reverse",
            "shingle",
            "snowballStemming",
            "stopword",
            "trim"
          ],
          "description": "Human-readable label that identifies this token filter type."
        }
      },
      "required": ["type"],
      "title": "TokenFilter"
    },
    "CharFilter": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": "string",
          "enum": ["htmlStrip", "icuNormalize", "mapping", "persian"],
          "description": "Human-readable label that identifies this character filter type."
        },
        "ignoredTags": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "List that contains the HTML tags to exclude from filtering."
        }
      },
      "dependencies": {
        "ignoredTags": {
          "properties": {
            "type": {
              "enum": ["htmlStrip"]
            }
          }
        }
      },
      "required": ["type"],
      "if": {
        "properties": {
          "type": {
            "const": "mapping"
          }
        }
      },
      "then": {
        "properties": {
          "mappings": {
            "type": "object"
          }
        },
        "required": ["mappings"]
      },
      "title": "CharFilter"
    },
    "Mappings": {
      "type": "object",
      "oneOf": [
        {
          "additionalProperties": false,
          "properties": {
            "dynamic": {
              "const": true
            }
          }
        },
        {
          "additionalProperties": false,
          "properties": {
            "dynamic": {
              "type": "boolean",
              "description": "Enables or disables dynamic mapping of fields for this index.\nIf set to true, Atlas Search recursively indexes all fields and embedded documents in the document except:\nFields of certain data types. To learn more, see BSON Data Types.\nAny fields explicitly excluded by the mappings.fields parameter.\nIf set to false, you must specify individual fields to index using mappings.fields.\nIf omitted, defaults to false."
            },
            "fields": {
              "type": "object",
              "patternProperties": {
                "^.*$": {
                  "oneOf": [
                    {
                      "$ref": "#/definitions/MappingsField"
                    },
                    {
                      "type": "array",
                      "items": {
                        "$ref": "#/definitions/MappingsField"
                      }
                    }
                  ]
                }
              }
            }
          },
          "required": ["fields"]
        }
      ],
      "title": "Mappings",
      "description": "Specifies how to index fields at different paths for this index."
    },
    "MappingsField": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "autocomplete",
            "boolean",
            "date",
            "dateFacet",
            "document",
            "embeddedDocuments",
            "geo",
            "number",
            "numberFacet",
            "objectId",
            "string",
            "stringFacet"
          ]
        },
        "analyzer": {
          "type": "string"
        },
        "maxGrams": {
          "type": "integer"
        },
        "minGrams": {
          "type": "integer"
        },
        "tokenization": {
          "type": "string",
          "enum": ["edgeGram", "rightEdgeGram", "nGram"]
        },
        "foldDiacritics": {
          "type": "boolean"
        },
        "dynamic": {
          "type": "boolean"
        },
        "fields": {
          "type": "object"
        },
        "indexShapes": {
          "type": "boolean"
        },
        "representation": {
          "type": "string",
          "enum": ["int64", "double"]
        },
        "indexIntegers": {
          "type": "boolean"
        },
        "indexDoubles": {
          "type": "boolean"
        },
        "searchAnalyzer": {
          "type": "string"
        },
        "indexOptions": {
          "type": "string",
          "enum": ["docs", "freqs", "positions", "offsets"]
        },
        "store": {
          "type": "boolean"
        },
        "ignoreAbove": {
          "type": "integer"
        },
        "multi": {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": ["string"]
            },
            "analyzer": {
              "type": "string"
            }
          }
        },
        "norms": {
          "type": "string",
          "enum": ["include", "omit"]
        }
      },
      "dependencies": {
        "analyzer": {
          "properties": {
            "type": {
              "enum": ["autocomplete", "string"]
            }
          }
        },
        "maxGrams": {
          "properties": {
            "type": {
              "enum": ["autocomplete"]
            }
          }
        },
        "minGrams": {
          "properties": {
            "type": {
              "enum": ["autocomplete"]
            }
          }
        },
        "tokenization": {
          "properties": {
            "type": {
              "enum": ["autocomplete"]
            }
          }
        },
        "foldDiacritics": {
          "properties": {
            "type": {
              "enum": ["autocomplete"]
            }
          }
        },
        "dynamic": {
          "properties": {
            "type": {
              "enum": ["document", "embeddedDocuments"]
            }
          }
        },
        "fields": {
          "properties": {
            "type": {
              "enum": ["document", "embeddedDocuments"]
            }
          }
        },
        "indexShapes": {
          "properties": {
            "type": {
              "enum": ["geo"]
            }
          }
        },
        "representation": {
          "properties": {
            "type": {
              "enum": ["number", "numberFacet"]
            }
          }
        },
        "indexIntegers": {
          "properties": {
            "type": {
              "enum": ["number", "numberFacet"]
            }
          }
        },
        "indexDoubles": {
          "properties": {
            "type": {
              "enum": ["number", "numberFacet"]
            }
          }
        },
        "searchAnalyzer": {
          "properties": {
            "type": {
              "enum": ["string"]
            }
          }
        },
        "indexOptions": {
          "properties": {
            "type": {
              "enum": ["string"]
            }
          }
        },
        "store": {
          "properties": {
            "type": {
              "enum": ["string"]
            }
          }
        },
        "ignoreAbove": {
          "properties": {
            "type": {
              "enum": ["string"]
            }
          }
        },
        "multi": {
          "properties": {
            "type": {
              "enum": ["string"]
            }
          }
        },
        "norms": {
          "properties": {
            "type": {
              "enum": ["string"]
            }
          }
        }
      }
    },
    "StoredSource": {
      "type": "object",
      "anyOf": [
        {
          "additionalProperties": false,
          "properties": {
            "include": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "List that contains the field names or dot-separated paths to fields to store.\nIn addition to the specified fields, Atlas Search stores _id also by default."
            },
            "exclude": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "List that contains the field names or dot-separated paths to fields to exclude from being stored.\nIf specified, Atlas Search stores original documents except the fields listed here."
            }
          },
          "required": ["include"]
        },
        {
          "additionalProperties": false,
          "properties": {
            "include": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "List that contains the field names or dot-separated paths to fields to store.\nIn addition to the specified fields, Atlas Search stores _id also by default."
            },
            "exclude": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "description": "List that contains the field names or dot-separated paths to fields to exclude from being stored.\nIf specified, Atlas Search stores original documents except the fields listed here."
            }
          },
          "required": ["exclude"]
        }
      ],
      "title": "StoredSource"
    },
    "Synonym": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string"
        },
        "analyzer": {
          "type": "string",
          "enum": [
            "lucene.standard",
            "lucene.simple",
            "lucene.whitespace",
            "lucene.keyword",
            "lucene.arabic",
            "lucene.armenian",
            "lucene.basque",
            "lucene.bengali",
            "lucene.brazilian",
            "lucene.bulgarian",
            "lucene.catalan",
            "lucene.chinese",
            "lucene.cjk",
            "lucene.czech",
            "lucene.danish",
            "lucene.dutch",
            "lucene.english",
            "lucene.finnish",
            "lucene.french",
            "lucene.galician",
            "lucene.german",
            "lucene.greek",
            "lucene.hindi",
            "lucene.hungarian",
            "lucene.indonesian",
            "lucene.irish",
            "lucene.italian",
            "lucene.japanese",
            "lucene.korean",
            "lucene.latvian",
            "lucene.lithuanian",
            "lucene.morfologik",
            "lucene.nori",
            "lucene.norwegian",
            "lucene.persian",
            "lucene.portuguese",
            "lucene.romanian",
            "lucene.russian",
            "lucene.smartcn",
            "lucene.sorani",
            "lucene.spanish",
            "lucene.swedish",
            "lucene.thai",
            "lucene.turkish",
            "lucene.ukrainian",
            "nGram",
            "edgeGram",
            "daitchMokotoffSoundex",
            "shingle"
          ]
        },
        "source": {
          "type": "object",
          "properties": {
            "collection": {
              "type": "string"
            }
          }
        }
      }
    }
  },
  "properties": {
    "analyzer": {
      "type": "string",
      "description": "Specifies the analyzer to apply to string fields when indexing.\nIf you set this only at the top and do not specify an analyzer for the fields in the index definition, Atlas Search applies this analyzer to all the fields.\nTo use a different analyzer for each field, you must specify a different analyzer for the field.\nIf omitted, defaults to Standard Analyzer."
    },
    "analyzers": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/CustomAnalyzer"
      },
      "description": "Specifies the Custom Analyzers to use in this index."
    },
    "mappings": {
      "$ref": "#/definitions/Mappings"
    },
    "name": {
      "type": "string",
      "description": "Specifies a name for the index. In each namespace, names of all indexes in the namespace must be unique.\nIf omitted, defaults to default."
    },
    "searchAnalyzer": {
      "type": "string",
      "description": "Specifies the analyzer to apply to query text before searching with it.\nIf omitted, defaults to Standard Analyzer."
    },
    "storedSource": {
      "oneOf": [
        {
          "type": "boolean"
        },
        {
          "$ref": "#/definitions/StoredSource"
        }
      ],
      "description": "Specifies fields in the documents to store for query-time look-ups using the returnedStoredSource option.\nYou can store fields of all BSON Data Types on Atlas Search.\n\nValue can be one of the following:\ntrue, to store all fields\nfalse, to not store any fields\nObject that specifies the fields to include or exclude from storage\n\nIf omitted, defaults to false."
    },
    "synonyms": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/Synonym"
      },
      "description": "Synonym mappings to use in your index."
    }
  },
  "required": ["mappings"],
  "title": "JSON schema for MongoDB Atlas Search index definition",
  "type": "object"
}
