{-# 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.CloudSearchDomains.Types.SuggestionMatch
-- 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.CloudSearchDomains.Types.SuggestionMatch where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An autocomplete suggestion that matches the query string specified in a
-- @SuggestRequest@.
--
-- /See:/ 'newSuggestionMatch' smart constructor.
data SuggestionMatch = SuggestionMatch'
  { -- | The string that matches the query string specified in the
    -- @SuggestRequest@.
    SuggestionMatch -> Maybe Text
suggestion :: Prelude.Maybe Prelude.Text,
    -- | The relevance score of a suggested match.
    SuggestionMatch -> Maybe Integer
score :: Prelude.Maybe Prelude.Integer,
    -- | The document ID of the suggested document.
    SuggestionMatch -> Maybe Text
id :: Prelude.Maybe Prelude.Text
  }
  deriving (SuggestionMatch -> SuggestionMatch -> Bool
(SuggestionMatch -> SuggestionMatch -> Bool)
-> (SuggestionMatch -> SuggestionMatch -> Bool)
-> Eq SuggestionMatch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SuggestionMatch -> SuggestionMatch -> Bool
$c/= :: SuggestionMatch -> SuggestionMatch -> Bool
== :: SuggestionMatch -> SuggestionMatch -> Bool
$c== :: SuggestionMatch -> SuggestionMatch -> Bool
Prelude.Eq, ReadPrec [SuggestionMatch]
ReadPrec SuggestionMatch
Int -> ReadS SuggestionMatch
ReadS [SuggestionMatch]
(Int -> ReadS SuggestionMatch)
-> ReadS [SuggestionMatch]
-> ReadPrec SuggestionMatch
-> ReadPrec [SuggestionMatch]
-> Read SuggestionMatch
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SuggestionMatch]
$creadListPrec :: ReadPrec [SuggestionMatch]
readPrec :: ReadPrec SuggestionMatch
$creadPrec :: ReadPrec SuggestionMatch
readList :: ReadS [SuggestionMatch]
$creadList :: ReadS [SuggestionMatch]
readsPrec :: Int -> ReadS SuggestionMatch
$creadsPrec :: Int -> ReadS SuggestionMatch
Prelude.Read, Int -> SuggestionMatch -> ShowS
[SuggestionMatch] -> ShowS
SuggestionMatch -> String
(Int -> SuggestionMatch -> ShowS)
-> (SuggestionMatch -> String)
-> ([SuggestionMatch] -> ShowS)
-> Show SuggestionMatch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SuggestionMatch] -> ShowS
$cshowList :: [SuggestionMatch] -> ShowS
show :: SuggestionMatch -> String
$cshow :: SuggestionMatch -> String
showsPrec :: Int -> SuggestionMatch -> ShowS
$cshowsPrec :: Int -> SuggestionMatch -> ShowS
Prelude.Show, (forall x. SuggestionMatch -> Rep SuggestionMatch x)
-> (forall x. Rep SuggestionMatch x -> SuggestionMatch)
-> Generic SuggestionMatch
forall x. Rep SuggestionMatch x -> SuggestionMatch
forall x. SuggestionMatch -> Rep SuggestionMatch x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SuggestionMatch x -> SuggestionMatch
$cfrom :: forall x. SuggestionMatch -> Rep SuggestionMatch x
Prelude.Generic)

-- |
-- Create a value of 'SuggestionMatch' 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:
--
-- 'suggestion', 'suggestionMatch_suggestion' - The string that matches the query string specified in the
-- @SuggestRequest@.
--
-- 'score', 'suggestionMatch_score' - The relevance score of a suggested match.
--
-- 'id', 'suggestionMatch_id' - The document ID of the suggested document.
newSuggestionMatch ::
  SuggestionMatch
newSuggestionMatch :: SuggestionMatch
newSuggestionMatch =
  SuggestionMatch' :: Maybe Text -> Maybe Integer -> Maybe Text -> SuggestionMatch
SuggestionMatch'
    { $sel:suggestion:SuggestionMatch' :: Maybe Text
suggestion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:score:SuggestionMatch' :: Maybe Integer
score = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:id:SuggestionMatch' :: Maybe Text
id = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The string that matches the query string specified in the
-- @SuggestRequest@.
suggestionMatch_suggestion :: Lens.Lens' SuggestionMatch (Prelude.Maybe Prelude.Text)
suggestionMatch_suggestion :: (Maybe Text -> f (Maybe Text))
-> SuggestionMatch -> f SuggestionMatch
suggestionMatch_suggestion = (SuggestionMatch -> Maybe Text)
-> (SuggestionMatch -> Maybe Text -> SuggestionMatch)
-> Lens SuggestionMatch SuggestionMatch (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuggestionMatch' {Maybe Text
suggestion :: Maybe Text
$sel:suggestion:SuggestionMatch' :: SuggestionMatch -> Maybe Text
suggestion} -> Maybe Text
suggestion) (\s :: SuggestionMatch
s@SuggestionMatch' {} Maybe Text
a -> SuggestionMatch
s {$sel:suggestion:SuggestionMatch' :: Maybe Text
suggestion = Maybe Text
a} :: SuggestionMatch)

-- | The relevance score of a suggested match.
suggestionMatch_score :: Lens.Lens' SuggestionMatch (Prelude.Maybe Prelude.Integer)
suggestionMatch_score :: (Maybe Integer -> f (Maybe Integer))
-> SuggestionMatch -> f SuggestionMatch
suggestionMatch_score = (SuggestionMatch -> Maybe Integer)
-> (SuggestionMatch -> Maybe Integer -> SuggestionMatch)
-> Lens
     SuggestionMatch SuggestionMatch (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuggestionMatch' {Maybe Integer
score :: Maybe Integer
$sel:score:SuggestionMatch' :: SuggestionMatch -> Maybe Integer
score} -> Maybe Integer
score) (\s :: SuggestionMatch
s@SuggestionMatch' {} Maybe Integer
a -> SuggestionMatch
s {$sel:score:SuggestionMatch' :: Maybe Integer
score = Maybe Integer
a} :: SuggestionMatch)

-- | The document ID of the suggested document.
suggestionMatch_id :: Lens.Lens' SuggestionMatch (Prelude.Maybe Prelude.Text)
suggestionMatch_id :: (Maybe Text -> f (Maybe Text))
-> SuggestionMatch -> f SuggestionMatch
suggestionMatch_id = (SuggestionMatch -> Maybe Text)
-> (SuggestionMatch -> Maybe Text -> SuggestionMatch)
-> Lens SuggestionMatch SuggestionMatch (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuggestionMatch' {Maybe Text
id :: Maybe Text
$sel:id:SuggestionMatch' :: SuggestionMatch -> Maybe Text
id} -> Maybe Text
id) (\s :: SuggestionMatch
s@SuggestionMatch' {} Maybe Text
a -> SuggestionMatch
s {$sel:id:SuggestionMatch' :: Maybe Text
id = Maybe Text
a} :: SuggestionMatch)

instance Core.FromJSON SuggestionMatch where
  parseJSON :: Value -> Parser SuggestionMatch
parseJSON =
    String
-> (Object -> Parser SuggestionMatch)
-> Value
-> Parser SuggestionMatch
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SuggestionMatch"
      ( \Object
x ->
          Maybe Text -> Maybe Integer -> Maybe Text -> SuggestionMatch
SuggestionMatch'
            (Maybe Text -> Maybe Integer -> Maybe Text -> SuggestionMatch)
-> Parser (Maybe Text)
-> Parser (Maybe Integer -> Maybe Text -> SuggestionMatch)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"suggestion")
            Parser (Maybe Integer -> Maybe Text -> SuggestionMatch)
-> Parser (Maybe Integer) -> Parser (Maybe Text -> SuggestionMatch)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"score")
            Parser (Maybe Text -> SuggestionMatch)
-> Parser (Maybe Text) -> Parser SuggestionMatch
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"id")
      )

instance Prelude.Hashable SuggestionMatch

instance Prelude.NFData SuggestionMatch