override def setup()

in backend/app/services/index/ElasticsearchResources.scala [28:91]


  override def setup(): Attempt[Index] = {
    createIndexIfNotAlreadyExists(indexName,
      properties(
        textField(IndexFields.`type`),
        emptyMultiLanguageField(IndexFields.text),
        emptyMultiLanguageField(IndexFields.ocr),
        emptyMultiLanguageField(IndexFields.transcript),
        textKeywordField(IndexFields.flags),
        dateField(IndexFields.createdAt),
        dateField(IndexFields.lastModifiedAt),
        booleanField(IndexFields.extracted),
        booleanField(IndexFields.ocrExtracted),
        booleanField(IndexFields.transcriptExtracted),
        textKeywordField(IndexFields.collection),
        textKeywordField(IndexFields.ingestion),
        keywordField(IndexFields.parentBlobs),
        nestedField(IndexFields.workspacesField).fields(
          keywordField(IndexFields.workspaces.workspaceId),
          keywordField(IndexFields.workspaces.workspaceNodeId),
          keywordField(IndexFields.workspaces.uri)
        ),
        ObjectField(IndexFields.metadataField, properties = Seq(
          // Normal Documents
          emptyMultiLanguageField(IndexFields.metadata.fileUris),
          textKeywordField(IndexFields.metadata.mimeTypes),
          longField(IndexFields.metadata.fileSize),
          nestedField(IndexFields.metadata.extractedMetadataField).fields(
            textKeywordField(NestedField.key).termVector("with_positions_offsets"),
            textField(NestedField.values).termVector("with_positions_offsets")
          ),
          ObjectField(IndexFields.metadata.enrichedMetadataField, properties = Seq(
            textKeywordField(IndexFields.metadata.enrichedMetadata.title),
            textKeywordField(IndexFields.metadata.enrichedMetadata.author),
            longField(IndexFields.metadata.enrichedMetadata.createdAt),
            longField(IndexFields.metadata.enrichedMetadata.lastModified),
            textKeywordField(IndexFields.metadata.enrichedMetadata.createdWith),
            intField(IndexFields.metadata.enrichedMetadata.pageCount),
            intField(IndexFields.metadata.enrichedMetadata.wordCount)
          )),

          // Emails Only
          ObjectField(IndexFields.metadata.fromField, properties = Seq(
            emptyMultiLanguageField(IndexFields.metadata.from.name),
            textField(IndexFields.metadata.from.address).termVector("with_positions_offsets")
          )),
          ObjectField(IndexFields.metadata.recipientsField, properties = Seq(
            emptyMultiLanguageField(IndexFields.metadata.recipients.name),
            textField(IndexFields.metadata.recipients.address).termVector("with_positions_offsets")
          )),
          textField(IndexFields.metadata.sentAt),
          textField(IndexFields.metadata.sensitivity).termVector("with_positions_offsets"),
          textField(IndexFields.metadata.priority).termVector("with_positions_offsets"),
          emptyMultiLanguageField(IndexFields.metadata.subject),
          textKeywordField(IndexFields.metadata.references),
          textKeywordField(IndexFields.metadata.inReplyTo),
          emptyMultiLanguageField(IndexFields.metadata.html),
          intField(IndexFields.metadata.attachmentCount)
        )
    ))).flatMap { _ =>
      Attempt.sequence(Languages.all.map(addLanguage))
    }.map { _ =>
      this
    }
  }