{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CloudSearch.Types.TextOptions where

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

-- | The name of an analysis scheme for a @text@ field.
textOptions_analysisScheme :: Lens.Lens' TextOptions (Prelude.Maybe Prelude.Text)
textOptions_analysisScheme :: Lens' TextOptions (Maybe Text)
textOptions_analysisScheme = 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)

-- | 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 :: Lens' TextOptions (Maybe Text)
textOptions_defaultValue = 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)

-- | Whether highlights can be returned for the field.
textOptions_highlightEnabled :: Lens.Lens' TextOptions (Prelude.Maybe Prelude.Bool)
textOptions_highlightEnabled :: Lens' TextOptions (Maybe Bool)
textOptions_highlightEnabled = 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 contents of the field can be returned in the search results.
textOptions_returnEnabled :: Lens.Lens' TextOptions (Prelude.Maybe Prelude.Bool)
textOptions_returnEnabled :: Lens' TextOptions (Maybe Bool)
textOptions_returnEnabled = 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)

-- | Whether the field can be used to sort the search results.
textOptions_sortEnabled :: Lens.Lens' TextOptions (Prelude.Maybe Prelude.Bool)
textOptions_sortEnabled :: Lens' TextOptions (Maybe Bool)
textOptions_sortEnabled = 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)

-- | Undocumented member.
textOptions_sourceField :: Lens.Lens' TextOptions (Prelude.Maybe Prelude.Text)
textOptions_sourceField :: Lens' TextOptions (Maybe Text)
textOptions_sourceField = 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)

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

instance Prelude.Hashable TextOptions where
  hashWithSalt :: Int -> TextOptions -> Int
hashWithSalt Int
_salt TextOptions' {Maybe Bool
Maybe Text
sourceField :: Maybe Text
sortEnabled :: Maybe Bool
returnEnabled :: Maybe Bool
highlightEnabled :: Maybe Bool
defaultValue :: Maybe Text
analysisScheme :: Maybe Text
$sel:sourceField:TextOptions' :: TextOptions -> Maybe Text
$sel:sortEnabled:TextOptions' :: TextOptions -> Maybe Bool
$sel:returnEnabled:TextOptions' :: TextOptions -> Maybe Bool
$sel:highlightEnabled:TextOptions' :: TextOptions -> Maybe Bool
$sel:defaultValue:TextOptions' :: TextOptions -> Maybe Text
$sel:analysisScheme:TextOptions' :: TextOptions -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
analysisScheme
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
defaultValue
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
highlightEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
returnEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
sortEnabled
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
sourceField

instance Prelude.NFData TextOptions where
  rnf :: TextOptions -> ()
rnf TextOptions' {Maybe Bool
Maybe Text
sourceField :: Maybe Text
sortEnabled :: Maybe Bool
returnEnabled :: Maybe Bool
highlightEnabled :: Maybe Bool
defaultValue :: Maybe Text
analysisScheme :: Maybe Text
$sel:sourceField:TextOptions' :: TextOptions -> Maybe Text
$sel:sortEnabled:TextOptions' :: TextOptions -> Maybe Bool
$sel:returnEnabled:TextOptions' :: TextOptions -> Maybe Bool
$sel:highlightEnabled:TextOptions' :: TextOptions -> Maybe Bool
$sel:defaultValue:TextOptions' :: TextOptions -> Maybe Text
$sel:analysisScheme:TextOptions' :: TextOptions -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
analysisScheme
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
defaultValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
highlightEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
returnEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
sortEnabled
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
sourceField

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