{-# 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.CloudSearch.Types.Suggester
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CloudSearch.Types.Suggester where

import Amazonka.CloudSearch.Types.DocumentSuggesterOptions
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Configuration information for a search suggester. Each suggester has a
-- unique name and specifies the text field you want to use for
-- suggestions. The following options can be configured for a suggester:
-- @FuzzyMatching@, @SortExpression@.
--
-- /See:/ 'newSuggester' smart constructor.
data Suggester = Suggester'
  { Suggester -> Text
suggesterName :: Prelude.Text,
    Suggester -> DocumentSuggesterOptions
documentSuggesterOptions :: DocumentSuggesterOptions
  }
  deriving (Suggester -> Suggester -> Bool
(Suggester -> Suggester -> Bool)
-> (Suggester -> Suggester -> Bool) -> Eq Suggester
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Suggester -> Suggester -> Bool
$c/= :: Suggester -> Suggester -> Bool
== :: Suggester -> Suggester -> Bool
$c== :: Suggester -> Suggester -> Bool
Prelude.Eq, ReadPrec [Suggester]
ReadPrec Suggester
Int -> ReadS Suggester
ReadS [Suggester]
(Int -> ReadS Suggester)
-> ReadS [Suggester]
-> ReadPrec Suggester
-> ReadPrec [Suggester]
-> Read Suggester
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Suggester]
$creadListPrec :: ReadPrec [Suggester]
readPrec :: ReadPrec Suggester
$creadPrec :: ReadPrec Suggester
readList :: ReadS [Suggester]
$creadList :: ReadS [Suggester]
readsPrec :: Int -> ReadS Suggester
$creadsPrec :: Int -> ReadS Suggester
Prelude.Read, Int -> Suggester -> ShowS
[Suggester] -> ShowS
Suggester -> String
(Int -> Suggester -> ShowS)
-> (Suggester -> String)
-> ([Suggester] -> ShowS)
-> Show Suggester
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Suggester] -> ShowS
$cshowList :: [Suggester] -> ShowS
show :: Suggester -> String
$cshow :: Suggester -> String
showsPrec :: Int -> Suggester -> ShowS
$cshowsPrec :: Int -> Suggester -> ShowS
Prelude.Show, (forall x. Suggester -> Rep Suggester x)
-> (forall x. Rep Suggester x -> Suggester) -> Generic Suggester
forall x. Rep Suggester x -> Suggester
forall x. Suggester -> Rep Suggester x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Suggester x -> Suggester
$cfrom :: forall x. Suggester -> Rep Suggester x
Prelude.Generic)

-- |
-- Create a value of 'Suggester' 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:
--
-- 'suggesterName', 'suggester_suggesterName' - Undocumented member.
--
-- 'documentSuggesterOptions', 'suggester_documentSuggesterOptions' - Undocumented member.
newSuggester ::
  -- | 'suggesterName'
  Prelude.Text ->
  -- | 'documentSuggesterOptions'
  DocumentSuggesterOptions ->
  Suggester
newSuggester :: Text -> DocumentSuggesterOptions -> Suggester
newSuggester
  Text
pSuggesterName_
  DocumentSuggesterOptions
pDocumentSuggesterOptions_ =
    Suggester' :: Text -> DocumentSuggesterOptions -> Suggester
Suggester'
      { $sel:suggesterName:Suggester' :: Text
suggesterName = Text
pSuggesterName_,
        $sel:documentSuggesterOptions:Suggester' :: DocumentSuggesterOptions
documentSuggesterOptions =
          DocumentSuggesterOptions
pDocumentSuggesterOptions_
      }

-- | Undocumented member.
suggester_suggesterName :: Lens.Lens' Suggester Prelude.Text
suggester_suggesterName :: (Text -> f Text) -> Suggester -> f Suggester
suggester_suggesterName = (Suggester -> Text)
-> (Suggester -> Text -> Suggester)
-> Lens Suggester Suggester Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Suggester' {Text
suggesterName :: Text
$sel:suggesterName:Suggester' :: Suggester -> Text
suggesterName} -> Text
suggesterName) (\s :: Suggester
s@Suggester' {} Text
a -> Suggester
s {$sel:suggesterName:Suggester' :: Text
suggesterName = Text
a} :: Suggester)

-- | Undocumented member.
suggester_documentSuggesterOptions :: Lens.Lens' Suggester DocumentSuggesterOptions
suggester_documentSuggesterOptions :: (DocumentSuggesterOptions -> f DocumentSuggesterOptions)
-> Suggester -> f Suggester
suggester_documentSuggesterOptions = (Suggester -> DocumentSuggesterOptions)
-> (Suggester -> DocumentSuggesterOptions -> Suggester)
-> Lens
     Suggester
     Suggester
     DocumentSuggesterOptions
     DocumentSuggesterOptions
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Suggester' {DocumentSuggesterOptions
documentSuggesterOptions :: DocumentSuggesterOptions
$sel:documentSuggesterOptions:Suggester' :: Suggester -> DocumentSuggesterOptions
documentSuggesterOptions} -> DocumentSuggesterOptions
documentSuggesterOptions) (\s :: Suggester
s@Suggester' {} DocumentSuggesterOptions
a -> Suggester
s {$sel:documentSuggesterOptions:Suggester' :: DocumentSuggesterOptions
documentSuggesterOptions = DocumentSuggesterOptions
a} :: Suggester)

instance Core.FromXML Suggester where
  parseXML :: [Node] -> Either String Suggester
parseXML [Node]
x =
    Text -> DocumentSuggesterOptions -> Suggester
Suggester'
      (Text -> DocumentSuggesterOptions -> Suggester)
-> Either String Text
-> Either String (DocumentSuggesterOptions -> Suggester)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"SuggesterName")
      Either String (DocumentSuggesterOptions -> Suggester)
-> Either String DocumentSuggesterOptions
-> Either String Suggester
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String DocumentSuggesterOptions
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"DocumentSuggesterOptions")

instance Prelude.Hashable Suggester

instance Prelude.NFData Suggester

instance Core.ToQuery Suggester where
  toQuery :: Suggester -> QueryString
toQuery Suggester' {Text
DocumentSuggesterOptions
documentSuggesterOptions :: DocumentSuggesterOptions
suggesterName :: Text
$sel:documentSuggesterOptions:Suggester' :: Suggester -> DocumentSuggesterOptions
$sel:suggesterName:Suggester' :: Suggester -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"SuggesterName" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
suggesterName,
        ByteString
"DocumentSuggesterOptions"
          ByteString -> DocumentSuggesterOptions -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: DocumentSuggesterOptions
documentSuggesterOptions
      ]