{-# 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.TextOptions
-- 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.TextOptions where

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

-- | Options for text field. Present if @IndexFieldType@ specifies the field
-- is of type @text@. A @text@ field is always searchable. All options are
-- enabled by default.
--
-- /See:/ 'newTextOptions' smart constructor.
data TextOptions = TextOptions'
  { TextOptions -> Maybe Text
sourceField :: Prelude.Maybe Prelude.Text,
    -- | Whether the contents of the field can be returned in the search results.
    TextOptions -> Maybe Bool
returnEnabled :: Prelude.Maybe Prelude.Bool,
    -- | The name of an analysis scheme for a @text@ field.
    TextOptions -> Maybe Text
analysisScheme :: Prelude.Maybe Prelude.Text,
    -- | Whether highlights can be returned for the field.
    TextOptions -> Maybe Bool
highlightEnabled :: Prelude.Maybe Prelude.Bool,
    -- | Whether the field can be used to sort the search results.
    TextOptions -> Maybe Bool
sortEnabled :: Prelude.Maybe Prelude.Bool,
    -- | A value to use for the field if the field isn\'t specified for a
    -- document.
    TextOptions -> Maybe Text
defaultValue :: Prelude.Maybe Prelude.Text
  }
  deriving (TextOptions -> TextOptions -> Bool
(TextOptions -> TextOptions -> Bool)
-> (TextOptions -> TextOptions -> Bool) -> Eq TextOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TextOptions -> TextOptions -> Bool
$c/= :: TextOptions -> TextOptions -> Bool
== :: TextOptions -> TextOptions -> Bool
$c== :: TextOptions -> TextOptions -> Bool
Prelude.Eq, ReadPrec [TextOptions]
ReadPrec TextOptions
Int -> ReadS TextOptions
ReadS [TextOptions]
(Int -> ReadS TextOptions)
-> ReadS [TextOptions]
-> ReadPrec TextOptions
-> ReadPrec [TextOptions]
-> Read TextOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TextOptions]
$creadListPrec :: ReadPrec [TextOptions]
readPrec :: ReadPrec TextOptions
$creadPrec :: ReadPrec TextOptions
readList :: ReadS [TextOptions]
$creadList :: ReadS [TextOptions]
readsPrec :: Int -> ReadS TextOptions
$creadsPrec :: Int -> ReadS TextOptions
Prelude.Read, Int -> TextOptions -> ShowS
[TextOptions] -> ShowS
TextOptions -> String
(Int -> TextOptions -> ShowS)
-> (TextOptions -> String)
-> ([TextOptions] -> ShowS)
-> Show TextOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TextOptions] -> ShowS
$cshowList :: [TextOptions] -> ShowS
show :: TextOptions -> String
$cshow :: TextOptions -> String
showsPrec :: Int -> TextOptions -> ShowS
$cshowsPrec :: Int -> TextOptions -> ShowS
Prelude.Show, (forall x. TextOptions -> Rep TextOptions x)
-> (forall x. Rep TextOptions x -> TextOptions)
-> Generic TextOptions
forall x. Rep TextOptions x -> TextOptions
forall x. TextOptions -> Rep TextOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TextOptions x -> TextOptions
$cfrom :: forall x. TextOptions -> Rep TextOptions x
Prelude.Generic)

-- |
-- Create a value of 'TextOptions' 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:
--
-- 'sourceField', 'textOptions_sourceField' - Undocumented member.
--
-- 'returnEnabled', 'textOptions_returnEnabled' - Whether the contents of the field can be returned in the search results.
--
-- 'analysisScheme', 'textOptions_analysisScheme' - The name of an analysis scheme for a @text@ field.
--
-- 'highlightEnabled', 'textOptions_highlightEnabled' - Whether highlights can be returned for the field.
--
-- 'sortEnabled', 'textOptions_sortEnabled' - Whether the field can be used to sort the search results.
--
-- 'defaultValue', 'textOptions_defaultValue' - A value to use for the field if the field isn\'t specified for a
-- document.
newTextOptions ::
  TextOptions
newTextOptions :: TextOptions
newTextOptions =
  TextOptions' :: Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Maybe Text
-> TextOptions
TextOptions'
    { $sel:sourceField:TextOptions' :: Maybe Text
sourceField = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:returnEnabled:TextOptions' :: Maybe Bool
returnEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:analysisScheme:TextOptions' :: Maybe Text
analysisScheme = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:highlightEnabled:TextOptions' :: Maybe Bool
highlightEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:sortEnabled:TextOptions' :: Maybe Bool
sortEnabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultValue:TextOptions' :: Maybe Text
defaultValue = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Undocumented member.
textOptions_sourceField :: Lens.Lens' TextOptions (Prelude.Maybe Prelude.Text)
textOptions_sourceField :: (Maybe Text -> f (Maybe Text)) -> TextOptions -> f TextOptions
textOptions_sourceField = (TextOptions -> Maybe Text)
-> (TextOptions -> Maybe Text -> TextOptions)
-> Lens TextOptions TextOptions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TextOptions' {Maybe Text
sourceField :: Maybe Text
$sel:sourceField:TextOptions' :: TextOptions -> Maybe Text
sourceField} -> Maybe Text
sourceField) (\s :: TextOptions
s@TextOptions' {} Maybe Text
a -> TextOptions
s {$sel:sourceField:TextOptions' :: Maybe Text
sourceField = Maybe Text
a} :: TextOptions)

-- | Whether the contents of the field can be returned in the search results.
textOptions_returnEnabled :: Lens.Lens' TextOptions (Prelude.Maybe Prelude.Bool)
textOptions_returnEnabled :: (Maybe Bool -> f (Maybe Bool)) -> TextOptions -> f TextOptions
textOptions_returnEnabled = (TextOptions -> Maybe Bool)
-> (TextOptions -> Maybe Bool -> TextOptions)
-> Lens TextOptions TextOptions (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TextOptions' {Maybe Bool
returnEnabled :: Maybe Bool
$sel:returnEnabled:TextOptions' :: TextOptions -> Maybe Bool
returnEnabled} -> Maybe Bool
returnEnabled) (\s :: TextOptions
s@TextOptions' {} Maybe Bool
a -> TextOptions
s {$sel:returnEnabled:TextOptions' :: Maybe Bool
returnEnabled = Maybe Bool
a} :: TextOptions)

-- | The name of an analysis scheme for a @text@ field.
textOptions_analysisScheme :: Lens.Lens' TextOptions (Prelude.Maybe Prelude.Text)
textOptions_analysisScheme :: (Maybe Text -> f (Maybe Text)) -> TextOptions -> f TextOptions
textOptions_analysisScheme = (TextOptions -> Maybe Text)
-> (TextOptions -> Maybe Text -> TextOptions)
-> Lens TextOptions TextOptions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TextOptions' {Maybe Text
analysisScheme :: Maybe Text
$sel:analysisScheme:TextOptions' :: TextOptions -> Maybe Text
analysisScheme} -> Maybe Text
analysisScheme) (\s :: TextOptions
s@TextOptions' {} Maybe Text
a -> TextOptions
s {$sel:analysisScheme:TextOptions' :: Maybe Text
analysisScheme = Maybe Text
a} :: TextOptions)

-- | Whether highlights can be returned for the field.
textOptions_highlightEnabled :: Lens.Lens' TextOptions (Prelude.Maybe Prelude.Bool)
textOptions_highlightEnabled :: (Maybe Bool -> f (Maybe Bool)) -> TextOptions -> f TextOptions
textOptions_highlightEnabled = (TextOptions -> Maybe Bool)
-> (TextOptions -> Maybe Bool -> TextOptions)
-> Lens TextOptions TextOptions (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TextOptions' {Maybe Bool
highlightEnabled :: Maybe Bool
$sel:highlightEnabled:TextOptions' :: TextOptions -> Maybe Bool
highlightEnabled} -> Maybe Bool
highlightEnabled) (\s :: TextOptions
s@TextOptions' {} Maybe Bool
a -> TextOptions
s {$sel:highlightEnabled:TextOptions' :: Maybe Bool
highlightEnabled = Maybe Bool
a} :: TextOptions)

-- | Whether the field can be used to sort the search results.
textOptions_sortEnabled :: Lens.Lens' TextOptions (Prelude.Maybe Prelude.Bool)
textOptions_sortEnabled :: (Maybe Bool -> f (Maybe Bool)) -> TextOptions -> f TextOptions
textOptions_sortEnabled = (TextOptions -> Maybe Bool)
-> (TextOptions -> Maybe Bool -> TextOptions)
-> Lens TextOptions TextOptions (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TextOptions' {Maybe Bool
sortEnabled :: Maybe Bool
$sel:sortEnabled:TextOptions' :: TextOptions -> Maybe Bool
sortEnabled} -> Maybe Bool
sortEnabled) (\s :: TextOptions
s@TextOptions' {} Maybe Bool
a -> TextOptions
s {$sel:sortEnabled:TextOptions' :: Maybe Bool
sortEnabled = Maybe Bool
a} :: TextOptions)

-- | A value to use for the field if the field isn\'t specified for a
-- document.
textOptions_defaultValue :: Lens.Lens' TextOptions (Prelude.Maybe Prelude.Text)
textOptions_defaultValue :: (Maybe Text -> f (Maybe Text)) -> TextOptions -> f TextOptions
textOptions_defaultValue = (TextOptions -> Maybe Text)
-> (TextOptions -> Maybe Text -> TextOptions)
-> Lens TextOptions TextOptions (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TextOptions' {Maybe Text
defaultValue :: Maybe Text
$sel:defaultValue:TextOptions' :: TextOptions -> Maybe Text
defaultValue} -> Maybe Text
defaultValue) (\s :: TextOptions
s@TextOptions' {} Maybe Text
a -> TextOptions
s {$sel:defaultValue:TextOptions' :: Maybe Text
defaultValue = Maybe Text
a} :: TextOptions)

instance Core.FromXML TextOptions where
  parseXML :: [Node] -> Either String TextOptions
parseXML [Node]
x =
    Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe Bool
-> Maybe Bool
-> Maybe Text
-> TextOptions
TextOptions'
      (Maybe Text
 -> Maybe Bool
 -> Maybe Text
 -> Maybe Bool
 -> Maybe Bool
 -> Maybe Text
 -> TextOptions)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Bool
      -> Maybe Text
      -> Maybe Bool
      -> Maybe Bool
      -> Maybe Text
      -> TextOptions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SourceField")
      Either
  String
  (Maybe Bool
   -> Maybe Text
   -> Maybe Bool
   -> Maybe Bool
   -> Maybe Text
   -> TextOptions)
-> Either String (Maybe Bool)
-> Either
     String
     (Maybe Text
      -> Maybe Bool -> Maybe Bool -> Maybe Text -> TextOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Bool)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ReturnEnabled")
      Either
  String
  (Maybe Text
   -> Maybe Bool -> Maybe Bool -> Maybe Text -> TextOptions)
-> Either String (Maybe Text)
-> Either
     String (Maybe Bool -> Maybe Bool -> Maybe Text -> TextOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"AnalysisScheme")
      Either
  String (Maybe Bool -> Maybe Bool -> Maybe Text -> TextOptions)
-> Either String (Maybe Bool)
-> Either String (Maybe Bool -> Maybe Text -> TextOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Bool)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"HighlightEnabled")
      Either String (Maybe Bool -> Maybe Text -> TextOptions)
-> Either String (Maybe Bool)
-> Either String (Maybe Text -> TextOptions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Bool)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SortEnabled")
      Either String (Maybe Text -> TextOptions)
-> Either String (Maybe Text) -> Either String TextOptions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DefaultValue")

instance Prelude.Hashable TextOptions

instance Prelude.NFData TextOptions

instance Core.ToQuery TextOptions where
  toQuery :: TextOptions -> QueryString
toQuery TextOptions' {Maybe Bool
Maybe Text
defaultValue :: Maybe Text
sortEnabled :: Maybe Bool
highlightEnabled :: Maybe Bool
analysisScheme :: Maybe Text
returnEnabled :: Maybe Bool
sourceField :: Maybe Text
$sel:defaultValue:TextOptions' :: TextOptions -> Maybe Text
$sel:sortEnabled:TextOptions' :: TextOptions -> Maybe Bool
$sel:highlightEnabled:TextOptions' :: TextOptions -> Maybe Bool
$sel:analysisScheme:TextOptions' :: TextOptions -> Maybe Text
$sel:returnEnabled:TextOptions' :: TextOptions -> Maybe Bool
$sel:sourceField:TextOptions' :: TextOptions -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"SourceField" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
sourceField,
        ByteString
"ReturnEnabled" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
returnEnabled,
        ByteString
"AnalysisScheme" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
analysisScheme,
        ByteString
"HighlightEnabled" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
highlightEnabled,
        ByteString
"SortEnabled" ByteString -> Maybe Bool -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Bool
sortEnabled,
        ByteString
"DefaultValue" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
defaultValue
      ]