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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Kendra.Types.DocumentAttributeValue
import {-# SOURCE #-} Amazonka.Kendra.Types.FacetResult
import qualified Amazonka.Prelude as Prelude

-- | Provides the count of documents that match a particular attribute when
-- doing a faceted search.
--
-- /See:/ 'newDocumentAttributeValueCountPair' smart constructor.
data DocumentAttributeValueCountPair = DocumentAttributeValueCountPair'
  { -- | The number of documents in the response that have the attribute value
    -- for the key.
    DocumentAttributeValueCountPair -> Maybe Int
count :: Prelude.Maybe Prelude.Int,
    -- | The value of the attribute. For example, \"HR\".
    DocumentAttributeValueCountPair -> Maybe DocumentAttributeValue
documentAttributeValue :: Prelude.Maybe DocumentAttributeValue,
    -- | Contains the results of a document attribute that is a nested facet. A
    -- @FacetResult@ contains the counts for each facet nested 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. The counts
    -- for documents that belong to \"Frontend\" and \"Backend\" within
    -- \"Engineering\" are returned for a query.
    DocumentAttributeValueCountPair -> Maybe [FacetResult]
facetResults :: Prelude.Maybe [FacetResult]
  }
  deriving (DocumentAttributeValueCountPair
-> DocumentAttributeValueCountPair -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentAttributeValueCountPair
-> DocumentAttributeValueCountPair -> Bool
$c/= :: DocumentAttributeValueCountPair
-> DocumentAttributeValueCountPair -> Bool
== :: DocumentAttributeValueCountPair
-> DocumentAttributeValueCountPair -> Bool
$c== :: DocumentAttributeValueCountPair
-> DocumentAttributeValueCountPair -> Bool
Prelude.Eq, ReadPrec [DocumentAttributeValueCountPair]
ReadPrec DocumentAttributeValueCountPair
Int -> ReadS DocumentAttributeValueCountPair
ReadS [DocumentAttributeValueCountPair]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentAttributeValueCountPair]
$creadListPrec :: ReadPrec [DocumentAttributeValueCountPair]
readPrec :: ReadPrec DocumentAttributeValueCountPair
$creadPrec :: ReadPrec DocumentAttributeValueCountPair
readList :: ReadS [DocumentAttributeValueCountPair]
$creadList :: ReadS [DocumentAttributeValueCountPair]
readsPrec :: Int -> ReadS DocumentAttributeValueCountPair
$creadsPrec :: Int -> ReadS DocumentAttributeValueCountPair
Prelude.Read, Int -> DocumentAttributeValueCountPair -> ShowS
[DocumentAttributeValueCountPair] -> ShowS
DocumentAttributeValueCountPair -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentAttributeValueCountPair] -> ShowS
$cshowList :: [DocumentAttributeValueCountPair] -> ShowS
show :: DocumentAttributeValueCountPair -> String
$cshow :: DocumentAttributeValueCountPair -> String
showsPrec :: Int -> DocumentAttributeValueCountPair -> ShowS
$cshowsPrec :: Int -> DocumentAttributeValueCountPair -> ShowS
Prelude.Show, forall x.
Rep DocumentAttributeValueCountPair x
-> DocumentAttributeValueCountPair
forall x.
DocumentAttributeValueCountPair
-> Rep DocumentAttributeValueCountPair x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DocumentAttributeValueCountPair x
-> DocumentAttributeValueCountPair
$cfrom :: forall x.
DocumentAttributeValueCountPair
-> Rep DocumentAttributeValueCountPair x
Prelude.Generic)

-- |
-- Create a value of 'DocumentAttributeValueCountPair' 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:
--
-- 'count', 'documentAttributeValueCountPair_count' - The number of documents in the response that have the attribute value
-- for the key.
--
-- 'documentAttributeValue', 'documentAttributeValueCountPair_documentAttributeValue' - The value of the attribute. For example, \"HR\".
--
-- 'facetResults', 'documentAttributeValueCountPair_facetResults' - Contains the results of a document attribute that is a nested facet. A
-- @FacetResult@ contains the counts for each facet nested 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. The counts
-- for documents that belong to \"Frontend\" and \"Backend\" within
-- \"Engineering\" are returned for a query.
newDocumentAttributeValueCountPair ::
  DocumentAttributeValueCountPair
newDocumentAttributeValueCountPair :: DocumentAttributeValueCountPair
newDocumentAttributeValueCountPair =
  DocumentAttributeValueCountPair'
    { $sel:count:DocumentAttributeValueCountPair' :: Maybe Int
count =
        forall a. Maybe a
Prelude.Nothing,
      $sel:documentAttributeValue:DocumentAttributeValueCountPair' :: Maybe DocumentAttributeValue
documentAttributeValue = forall a. Maybe a
Prelude.Nothing,
      $sel:facetResults:DocumentAttributeValueCountPair' :: Maybe [FacetResult]
facetResults = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of documents in the response that have the attribute value
-- for the key.
documentAttributeValueCountPair_count :: Lens.Lens' DocumentAttributeValueCountPair (Prelude.Maybe Prelude.Int)
documentAttributeValueCountPair_count :: Lens' DocumentAttributeValueCountPair (Maybe Int)
documentAttributeValueCountPair_count = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentAttributeValueCountPair' {Maybe Int
count :: Maybe Int
$sel:count:DocumentAttributeValueCountPair' :: DocumentAttributeValueCountPair -> Maybe Int
count} -> Maybe Int
count) (\s :: DocumentAttributeValueCountPair
s@DocumentAttributeValueCountPair' {} Maybe Int
a -> DocumentAttributeValueCountPair
s {$sel:count:DocumentAttributeValueCountPair' :: Maybe Int
count = Maybe Int
a} :: DocumentAttributeValueCountPair)

-- | The value of the attribute. For example, \"HR\".
documentAttributeValueCountPair_documentAttributeValue :: Lens.Lens' DocumentAttributeValueCountPair (Prelude.Maybe DocumentAttributeValue)
documentAttributeValueCountPair_documentAttributeValue :: Lens'
  DocumentAttributeValueCountPair (Maybe DocumentAttributeValue)
documentAttributeValueCountPair_documentAttributeValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentAttributeValueCountPair' {Maybe DocumentAttributeValue
documentAttributeValue :: Maybe DocumentAttributeValue
$sel:documentAttributeValue:DocumentAttributeValueCountPair' :: DocumentAttributeValueCountPair -> Maybe DocumentAttributeValue
documentAttributeValue} -> Maybe DocumentAttributeValue
documentAttributeValue) (\s :: DocumentAttributeValueCountPair
s@DocumentAttributeValueCountPair' {} Maybe DocumentAttributeValue
a -> DocumentAttributeValueCountPair
s {$sel:documentAttributeValue:DocumentAttributeValueCountPair' :: Maybe DocumentAttributeValue
documentAttributeValue = Maybe DocumentAttributeValue
a} :: DocumentAttributeValueCountPair)

-- | Contains the results of a document attribute that is a nested facet. A
-- @FacetResult@ contains the counts for each facet nested 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. The counts
-- for documents that belong to \"Frontend\" and \"Backend\" within
-- \"Engineering\" are returned for a query.
documentAttributeValueCountPair_facetResults :: Lens.Lens' DocumentAttributeValueCountPair (Prelude.Maybe [FacetResult])
documentAttributeValueCountPair_facetResults :: Lens' DocumentAttributeValueCountPair (Maybe [FacetResult])
documentAttributeValueCountPair_facetResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DocumentAttributeValueCountPair' {Maybe [FacetResult]
facetResults :: Maybe [FacetResult]
$sel:facetResults:DocumentAttributeValueCountPair' :: DocumentAttributeValueCountPair -> Maybe [FacetResult]
facetResults} -> Maybe [FacetResult]
facetResults) (\s :: DocumentAttributeValueCountPair
s@DocumentAttributeValueCountPair' {} Maybe [FacetResult]
a -> DocumentAttributeValueCountPair
s {$sel:facetResults:DocumentAttributeValueCountPair' :: Maybe [FacetResult]
facetResults = Maybe [FacetResult]
a} :: DocumentAttributeValueCountPair) 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

instance
  Data.FromJSON
    DocumentAttributeValueCountPair
  where
  parseJSON :: Value -> Parser DocumentAttributeValueCountPair
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DocumentAttributeValueCountPair"
      ( \Object
x ->
          Maybe Int
-> Maybe DocumentAttributeValue
-> Maybe [FacetResult]
-> DocumentAttributeValueCountPair
DocumentAttributeValueCountPair'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Count")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"DocumentAttributeValue")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"FacetResults" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance
  Prelude.Hashable
    DocumentAttributeValueCountPair
  where
  hashWithSalt :: Int -> DocumentAttributeValueCountPair -> Int
hashWithSalt
    Int
_salt
    DocumentAttributeValueCountPair' {Maybe Int
Maybe [FacetResult]
Maybe DocumentAttributeValue
facetResults :: Maybe [FacetResult]
documentAttributeValue :: Maybe DocumentAttributeValue
count :: Maybe Int
$sel:facetResults:DocumentAttributeValueCountPair' :: DocumentAttributeValueCountPair -> Maybe [FacetResult]
$sel:documentAttributeValue:DocumentAttributeValueCountPair' :: DocumentAttributeValueCountPair -> Maybe DocumentAttributeValue
$sel:count:DocumentAttributeValueCountPair' :: DocumentAttributeValueCountPair -> Maybe Int
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
count
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DocumentAttributeValue
documentAttributeValue
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [FacetResult]
facetResults

instance
  Prelude.NFData
    DocumentAttributeValueCountPair
  where
  rnf :: DocumentAttributeValueCountPair -> ()
rnf DocumentAttributeValueCountPair' {Maybe Int
Maybe [FacetResult]
Maybe DocumentAttributeValue
facetResults :: Maybe [FacetResult]
documentAttributeValue :: Maybe DocumentAttributeValue
count :: Maybe Int
$sel:facetResults:DocumentAttributeValueCountPair' :: DocumentAttributeValueCountPair -> Maybe [FacetResult]
$sel:documentAttributeValue:DocumentAttributeValueCountPair' :: DocumentAttributeValueCountPair -> Maybe DocumentAttributeValue
$sel:count:DocumentAttributeValueCountPair' :: DocumentAttributeValueCountPair -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
count
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DocumentAttributeValue
documentAttributeValue
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [FacetResult]
facetResults