All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sksamuel.elastic4s.requests.indexes.AnalysisDefinition.scala Maven / Gradle / Ivy

There is a newer version: 8.15.4
Show newest version
package com.sksamuel.elastic4s.requests.indexes

import com.sksamuel.elastic4s.requests.analyzers.{AnalyzerDefinition, CharFilterDefinition, CustomAnalyzerDefinition, CustomNormalizerDefinition, NormalizerDefinition, TokenFilterDefinition, Tokenizer}

@deprecated("use new analysis package", "7.0.1")
case class AnalysisDefinition(analyzers: Iterable[AnalyzerDefinition],
                              normalizers: Iterable[NormalizerDefinition]) {

  @deprecated("use new analysis package", "7.0.1")
  def tokenizers: Iterable[Tokenizer] =
    analyzers
      .collect {
        case custom: CustomAnalyzerDefinition => custom
      }
      .map(_.tokenizer)
      .filter(_.customized)

  @deprecated("use new analysis package", "7.0.1")
  def tokenFilterDefinitions: Iterable[TokenFilterDefinition] = {
    val fromAnalyzers = analyzers
      .collect {
        case custom: CustomAnalyzerDefinition => custom
      }
      .flatMap(_.filters)
    val fromNormalizers = normalizers
      .collect {
        case custom: CustomNormalizerDefinition => custom
      }
      .flatMap(_.filters)

    (fromAnalyzers ++ fromNormalizers).collect {
      case token: TokenFilterDefinition => token
    }
  }

  @deprecated("use new analysis package", "7.0.1")
  def charFilterDefinitions: Iterable[CharFilterDefinition] = {
    val fromAnalyzers = analyzers
      .collect {
        case custom: CustomAnalyzerDefinition => custom
      }
      .flatMap(_.filters)
    val fromNormalizers = normalizers
      .collect {
        case custom: CustomNormalizerDefinition => custom
      }
      .flatMap(_.filters)

    (fromAnalyzers ++ fromNormalizers).collect {
      case char: CharFilterDefinition => char
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy