{-# 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.Facet
-- 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.Facet 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

-- | Information about a document attribute. You can use document attributes
-- as facets.
--
-- For example, the document attribute or facet \"Department\" includes the
-- values \"HR\", \"Engineering\", and \"Accounting\". You can display
-- these values in the search results so that documents can be searched by
-- department.
--
-- You can display up to 10 facet values per facet for a query. If you want
-- to increase this limit, contact
-- <http://aws.amazon.com/contact-us/ Support>.
--
-- /See:/ 'newFacet' smart constructor.
data Facet = Facet'
  { -- | The unique key for the document attribute.
    Facet -> Maybe Text
documentAttributeKey :: Prelude.Maybe Prelude.Text,
    -- | An array of document attributes that are nested facets within a facet.
    --
    -- For example, the document attribute or facet \"Department\" includes a
    -- value called \"Engineering\". In addition, the document attribute or
    -- facet \"SubDepartment\" includes the values \"Frontend\" and \"Backend\"
    -- for documents assigned to \"Engineering\". You can display nested facets
    -- in the search results so that documents can be searched not only by
    -- department but also by a sub department within a department. This helps
    -- your users further narrow their search.
    --
    -- You can only have one nested facet within a facet. If you want to
    -- increase this limit, contact
    -- <http://aws.amazon.com/contact-us/ Support>.
    Facet -> Maybe [Facet]
facets :: Prelude.Maybe [Facet],
    -- | Maximum number of facet values per facet. The default is 10. You can use
    -- this to limit the number of facet values to less than 10. If you want to
    -- increase the default, contact
    -- <http://aws.amazon.com/contact-us/ Support>.
    Facet -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (Facet -> Facet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Facet -> Facet -> Bool
$c/= :: Facet -> Facet -> Bool
== :: Facet -> Facet -> Bool
$c== :: Facet -> Facet -> Bool
Prelude.Eq, ReadPrec [Facet]
ReadPrec Facet
Int -> ReadS Facet
ReadS [Facet]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Facet]
$creadListPrec :: ReadPrec [Facet]
readPrec :: ReadPrec Facet
$creadPrec :: ReadPrec Facet
readList :: ReadS [Facet]
$creadList :: ReadS [Facet]
readsPrec :: Int -> ReadS Facet
$creadsPrec :: Int -> ReadS Facet
Prelude.Read, Int -> Facet -> ShowS
[Facet] -> ShowS
Facet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Facet] -> ShowS
$cshowList :: [Facet] -> ShowS
show :: Facet -> String
$cshow :: Facet -> String
showsPrec :: Int -> Facet -> ShowS
$cshowsPrec :: Int -> Facet -> ShowS
Prelude.Show, forall x. Rep Facet x -> Facet
forall x. Facet -> Rep Facet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Facet x -> Facet
$cfrom :: forall x. Facet -> Rep Facet x
Prelude.Generic)

-- |
-- Create a value of 'Facet' 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:
--
-- 'documentAttributeKey', 'facet_documentAttributeKey' - The unique key for the document attribute.
--
-- 'facets', 'facet_facets' - An array of document attributes that are nested facets within a facet.
--
-- For example, the document attribute or facet \"Department\" includes a
-- value called \"Engineering\". In addition, the document attribute or
-- facet \"SubDepartment\" includes the values \"Frontend\" and \"Backend\"
-- for documents assigned to \"Engineering\". You can display nested facets
-- in the search results so that documents can be searched not only by
-- department but also by a sub department within a department. This helps
-- your users further narrow their search.
--
-- You can only have one nested facet within a facet. If you want to
-- increase this limit, contact
-- <http://aws.amazon.com/contact-us/ Support>.
--
-- 'maxResults', 'facet_maxResults' - Maximum number of facet values per facet. The default is 10. You can use
-- this to limit the number of facet values to less than 10. If you want to
-- increase the default, contact
-- <http://aws.amazon.com/contact-us/ Support>.
newFacet ::
  Facet
newFacet :: Facet
newFacet =
  Facet'
    { $sel:documentAttributeKey:Facet' :: Maybe Text
documentAttributeKey = forall a. Maybe a
Prelude.Nothing,
      $sel:facets:Facet' :: Maybe [Facet]
facets = forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:Facet' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing
    }

-- | The unique key for the document attribute.
facet_documentAttributeKey :: Lens.Lens' Facet (Prelude.Maybe Prelude.Text)
facet_documentAttributeKey :: Lens' Facet (Maybe Text)
facet_documentAttributeKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Facet' {Maybe Text
documentAttributeKey :: Maybe Text
$sel:documentAttributeKey:Facet' :: Facet -> Maybe Text
documentAttributeKey} -> Maybe Text
documentAttributeKey) (\s :: Facet
s@Facet' {} Maybe Text
a -> Facet
s {$sel:documentAttributeKey:Facet' :: Maybe Text
documentAttributeKey = Maybe Text
a} :: Facet)

-- | An array of document attributes that are nested facets within a facet.
--
-- For example, the document attribute or facet \"Department\" includes a
-- value called \"Engineering\". In addition, the document attribute or
-- facet \"SubDepartment\" includes the values \"Frontend\" and \"Backend\"
-- for documents assigned to \"Engineering\". You can display nested facets
-- in the search results so that documents can be searched not only by
-- department but also by a sub department within a department. This helps
-- your users further narrow their search.
--
-- You can only have one nested facet within a facet. If you want to
-- increase this limit, contact
-- <http://aws.amazon.com/contact-us/ Support>.
facet_facets :: Lens.Lens' Facet (Prelude.Maybe [Facet])
facet_facets :: Lens' Facet (Maybe [Facet])
facet_facets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Facet' {Maybe [Facet]
facets :: Maybe [Facet]
$sel:facets:Facet' :: Facet -> Maybe [Facet]
facets} -> Maybe [Facet]
facets) (\s :: Facet
s@Facet' {} Maybe [Facet]
a -> Facet
s {$sel:facets:Facet' :: Maybe [Facet]
facets = Maybe [Facet]
a} :: Facet) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Maximum number of facet values per facet. The default is 10. You can use
-- this to limit the number of facet values to less than 10. If you want to
-- increase the default, contact
-- <http://aws.amazon.com/contact-us/ Support>.
facet_maxResults :: Lens.Lens' Facet (Prelude.Maybe Prelude.Natural)
facet_maxResults :: Lens' Facet (Maybe Natural)
facet_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Facet' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:Facet' :: Facet -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: Facet
s@Facet' {} Maybe Natural
a -> Facet
s {$sel:maxResults:Facet' :: Maybe Natural
maxResults = Maybe Natural
a} :: Facet)

instance Prelude.Hashable Facet where
  hashWithSalt :: Int -> Facet -> Int
hashWithSalt Int
_salt Facet' {Maybe Natural
Maybe [Facet]
Maybe Text
maxResults :: Maybe Natural
facets :: Maybe [Facet]
documentAttributeKey :: Maybe Text
$sel:maxResults:Facet' :: Facet -> Maybe Natural
$sel:facets:Facet' :: Facet -> Maybe [Facet]
$sel:documentAttributeKey:Facet' :: Facet -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
documentAttributeKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Facet]
facets
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults

instance Prelude.NFData Facet where
  rnf :: Facet -> ()
rnf Facet' {Maybe Natural
Maybe [Facet]
Maybe Text
maxResults :: Maybe Natural
facets :: Maybe [Facet]
documentAttributeKey :: Maybe Text
$sel:maxResults:Facet' :: Facet -> Maybe Natural
$sel:facets:Facet' :: Facet -> Maybe [Facet]
$sel:documentAttributeKey:Facet' :: Facet -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
documentAttributeKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Facet]
facets
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults

instance Data.ToJSON Facet where
  toJSON :: Facet -> Value
toJSON Facet' {Maybe Natural
Maybe [Facet]
Maybe Text
maxResults :: Maybe Natural
facets :: Maybe [Facet]
documentAttributeKey :: Maybe Text
$sel:maxResults:Facet' :: Facet -> Maybe Natural
$sel:facets:Facet' :: Facet -> Maybe [Facet]
$sel:documentAttributeKey:Facet' :: Facet -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"DocumentAttributeKey" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
documentAttributeKey,
            (Key
"Facets" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Facet]
facets,
            (Key
"MaxResults" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxResults
          ]
      )