{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Kendra.Types.DocumentRelevanceConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Kendra.Types.DocumentRelevanceConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Kendra.Types.Relevance
import qualified Amazonka.Prelude as Prelude

-- | Overrides the document relevance properties of a custom index field.
--
-- /See:/ 'newDocumentRelevanceConfiguration' smart constructor.
data DocumentRelevanceConfiguration = DocumentRelevanceConfiguration'
  { -- | The name of the index field.
    DocumentRelevanceConfiguration -> Text
name :: Prelude.Text,
    -- | Provides information for tuning the relevance of a field in a search.
    -- When a query includes terms that match the field, the results are given
    -- a boost in the response based on these tuning parameters.
    DocumentRelevanceConfiguration -> Relevance
relevance :: Relevance
  }
  deriving (DocumentRelevanceConfiguration
-> DocumentRelevanceConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentRelevanceConfiguration
-> DocumentRelevanceConfiguration -> Bool
$c/= :: DocumentRelevanceConfiguration
-> DocumentRelevanceConfiguration -> Bool
== :: DocumentRelevanceConfiguration
-> DocumentRelevanceConfiguration -> Bool
$c== :: DocumentRelevanceConfiguration
-> DocumentRelevanceConfiguration -> Bool
Prelude.Eq, ReadPrec [DocumentRelevanceConfiguration]
ReadPrec DocumentRelevanceConfiguration
Int -> ReadS DocumentRelevanceConfiguration
ReadS [DocumentRelevanceConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentRelevanceConfiguration]
$creadListPrec :: ReadPrec [DocumentRelevanceConfiguration]
readPrec :: ReadPrec DocumentRelevanceConfiguration
$creadPrec :: ReadPrec DocumentRelevanceConfiguration
readList :: ReadS [DocumentRelevanceConfiguration]
$creadList :: ReadS [DocumentRelevanceConfiguration]
readsPrec :: Int -> ReadS DocumentRelevanceConfiguration
$creadsPrec :: Int -> ReadS DocumentRelevanceConfiguration
Prelude.Read, Int -> DocumentRelevanceConfiguration -> ShowS
[DocumentRelevanceConfiguration] -> ShowS
DocumentRelevanceConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentRelevanceConfiguration] -> ShowS
$cshowList :: [DocumentRelevanceConfiguration] -> ShowS
show :: DocumentRelevanceConfiguration -> String
$cshow :: DocumentRelevanceConfiguration -> String
showsPrec :: Int -> DocumentRelevanceConfiguration -> ShowS
$cshowsPrec :: Int -> DocumentRelevanceConfiguration -> ShowS
Prelude.Show, forall x.
Rep DocumentRelevanceConfiguration x
-> DocumentRelevanceConfiguration
forall x.
DocumentRelevanceConfiguration
-> Rep DocumentRelevanceConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DocumentRelevanceConfiguration x
-> DocumentRelevanceConfiguration
$cfrom :: forall x.
DocumentRelevanceConfiguration
-> Rep DocumentRelevanceConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'DocumentRelevanceConfiguration' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'name', 'documentRelevanceConfiguration_name' - The name of the index field.
--
-- 'relevance', 'documentRelevanceConfiguration_relevance' - Provides information for tuning the relevance of a field in a search.
-- When a query includes terms that match the field, the results are given
-- a boost in the response based on these tuning parameters.
newDocumentRelevanceConfiguration ::
  -- | 'name'
  Prelude.Text ->
  -- | 'relevance'
  Relevance ->
  DocumentRelevanceConfiguration
newDocumentRelevanceConfiguration :: Text -> Relevance -> DocumentRelevanceConfiguration
newDocumentRelevanceConfiguration Text
pName_ Relevance
pRelevance_ =
  DocumentRelevanceConfiguration'
    { $sel:name:DocumentRelevanceConfiguration' :: Text
name = Text
pName_,
      $sel:relevance:DocumentRelevanceConfiguration' :: Relevance
relevance = Relevance
pRelevance_
    }

-- | The name of the index field.
documentRelevanceConfiguration_name :: Lens.Lens' DocumentRelevanceConfiguration Prelude.Text
documentRelevanceConfiguration_name :: Lens' DocumentRelevanceConfiguration Text
documentRelevanceConfiguration_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentRelevanceConfiguration' {Text
name :: Text
$sel:name:DocumentRelevanceConfiguration' :: DocumentRelevanceConfiguration -> Text
name} -> Text
name) (\s :: DocumentRelevanceConfiguration
s@DocumentRelevanceConfiguration' {} Text
a -> DocumentRelevanceConfiguration
s {$sel:name:DocumentRelevanceConfiguration' :: Text
name = Text
a} :: DocumentRelevanceConfiguration)

-- | Provides information for tuning the relevance of a field in a search.
-- When a query includes terms that match the field, the results are given
-- a boost in the response based on these tuning parameters.
documentRelevanceConfiguration_relevance :: Lens.Lens' DocumentRelevanceConfiguration Relevance
documentRelevanceConfiguration_relevance :: Lens' DocumentRelevanceConfiguration Relevance
documentRelevanceConfiguration_relevance = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentRelevanceConfiguration' {Relevance
relevance :: Relevance
$sel:relevance:DocumentRelevanceConfiguration' :: DocumentRelevanceConfiguration -> Relevance
relevance} -> Relevance
relevance) (\s :: DocumentRelevanceConfiguration
s@DocumentRelevanceConfiguration' {} Relevance
a -> DocumentRelevanceConfiguration
s {$sel:relevance:DocumentRelevanceConfiguration' :: Relevance
relevance = Relevance
a} :: DocumentRelevanceConfiguration)

instance
  Prelude.Hashable
    DocumentRelevanceConfiguration
  where
  hashWithSalt :: Int -> DocumentRelevanceConfiguration -> Int
hashWithSalt
    Int
_salt
    DocumentRelevanceConfiguration' {Text
Relevance
relevance :: Relevance
name :: Text
$sel:relevance:DocumentRelevanceConfiguration' :: DocumentRelevanceConfiguration -> Relevance
$sel:name:DocumentRelevanceConfiguration' :: DocumentRelevanceConfiguration -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Relevance
relevance

instance
  Prelude.NFData
    DocumentRelevanceConfiguration
  where
  rnf :: DocumentRelevanceConfiguration -> ()
rnf DocumentRelevanceConfiguration' {Text
Relevance
relevance :: Relevance
name :: Text
$sel:relevance:DocumentRelevanceConfiguration' :: DocumentRelevanceConfiguration -> Relevance
$sel:name:DocumentRelevanceConfiguration' :: DocumentRelevanceConfiguration -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Relevance
relevance

instance Data.ToJSON DocumentRelevanceConfiguration where
  toJSON :: DocumentRelevanceConfiguration -> Value
toJSON DocumentRelevanceConfiguration' {Text
Relevance
relevance :: Relevance
name :: Text
$sel:relevance:DocumentRelevanceConfiguration' :: DocumentRelevanceConfiguration -> Relevance
$sel:name:DocumentRelevanceConfiguration' :: DocumentRelevanceConfiguration -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Relevance" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Relevance
relevance)
          ]
      )