{-# LANGUAGE OverloadedStrings #-}
module Database.Bloodhound.Internal.Versions.Common.Types.Highlight where
import qualified Data.Map.Strict as M
import Database.Bloodhound.Internal.Utils.Imports
import Database.Bloodhound.Internal.Versions.Common.Types.Newtypes
import Database.Bloodhound.Internal.Versions.Common.Types.Query
type HitHighlight = M.Map Text [Text]
data Highlights = Highlights
{ Highlights -> Maybe HighlightSettings
globalsettings :: Maybe HighlightSettings,
Highlights -> [FieldHighlight]
highlightFields :: [FieldHighlight]
}
deriving stock (Highlights -> Highlights -> Bool
(Highlights -> Highlights -> Bool)
-> (Highlights -> Highlights -> Bool) -> Eq Highlights
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Highlights -> Highlights -> Bool
== :: Highlights -> Highlights -> Bool
$c/= :: Highlights -> Highlights -> Bool
/= :: Highlights -> Highlights -> Bool
Eq, Int -> Highlights -> ShowS
[Highlights] -> ShowS
Highlights -> String
(Int -> Highlights -> ShowS)
-> (Highlights -> String)
-> ([Highlights] -> ShowS)
-> Show Highlights
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Highlights -> ShowS
showsPrec :: Int -> Highlights -> ShowS
$cshow :: Highlights -> String
show :: Highlights -> String
$cshowList :: [Highlights] -> ShowS
showList :: [Highlights] -> ShowS
Show)
instance ToJSON Highlights where
toJSON :: Highlights -> Value
toJSON (Highlights Maybe HighlightSettings
global [FieldHighlight]
fields) =
[Pair] -> Value
omitNulls
( (Key
"fields" Key -> [FieldHighlight] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [FieldHighlight]
fields)
Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Maybe HighlightSettings -> [Pair]
highlightSettingsPairs Maybe HighlightSettings
global
)
data FieldHighlight
= FieldHighlight FieldName (Maybe HighlightSettings)
deriving stock (FieldHighlight -> FieldHighlight -> Bool
(FieldHighlight -> FieldHighlight -> Bool)
-> (FieldHighlight -> FieldHighlight -> Bool) -> Eq FieldHighlight
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FieldHighlight -> FieldHighlight -> Bool
== :: FieldHighlight -> FieldHighlight -> Bool
$c/= :: FieldHighlight -> FieldHighlight -> Bool
/= :: FieldHighlight -> FieldHighlight -> Bool
Eq, Int -> FieldHighlight -> ShowS
[FieldHighlight] -> ShowS
FieldHighlight -> String
(Int -> FieldHighlight -> ShowS)
-> (FieldHighlight -> String)
-> ([FieldHighlight] -> ShowS)
-> Show FieldHighlight
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FieldHighlight -> ShowS
showsPrec :: Int -> FieldHighlight -> ShowS
$cshow :: FieldHighlight -> String
show :: FieldHighlight -> String
$cshowList :: [FieldHighlight] -> ShowS
showList :: [FieldHighlight] -> ShowS
Show)
instance ToJSON FieldHighlight where
toJSON :: FieldHighlight -> Value
toJSON (FieldHighlight (FieldName Text
fName) (Just HighlightSettings
fSettings)) =
[Pair] -> Value
object [Text -> Key
fromText Text
fName Key -> HighlightSettings -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= HighlightSettings
fSettings]
toJSON (FieldHighlight (FieldName Text
fName) Maybe HighlightSettings
Nothing) =
[Pair] -> Value
object [Text -> Key
fromText Text
fName Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Value
emptyObject]
data HighlightSettings
= Plain PlainHighlight
| Postings PostingsHighlight
| FastVector FastVectorHighlight
deriving stock (HighlightSettings -> HighlightSettings -> Bool
(HighlightSettings -> HighlightSettings -> Bool)
-> (HighlightSettings -> HighlightSettings -> Bool)
-> Eq HighlightSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HighlightSettings -> HighlightSettings -> Bool
== :: HighlightSettings -> HighlightSettings -> Bool
$c/= :: HighlightSettings -> HighlightSettings -> Bool
/= :: HighlightSettings -> HighlightSettings -> Bool
Eq, Int -> HighlightSettings -> ShowS
[HighlightSettings] -> ShowS
HighlightSettings -> String
(Int -> HighlightSettings -> ShowS)
-> (HighlightSettings -> String)
-> ([HighlightSettings] -> ShowS)
-> Show HighlightSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HighlightSettings -> ShowS
showsPrec :: Int -> HighlightSettings -> ShowS
$cshow :: HighlightSettings -> String
show :: HighlightSettings -> String
$cshowList :: [HighlightSettings] -> ShowS
showList :: [HighlightSettings] -> ShowS
Show)
instance ToJSON HighlightSettings where
toJSON :: HighlightSettings -> Value
toJSON HighlightSettings
hs = [Pair] -> Value
omitNulls (Maybe HighlightSettings -> [Pair]
highlightSettingsPairs (HighlightSettings -> Maybe HighlightSettings
forall a. a -> Maybe a
Just HighlightSettings
hs))
data PlainHighlight = PlainHighlight
{ PlainHighlight -> Maybe CommonHighlight
plainCommon :: Maybe CommonHighlight,
PlainHighlight -> Maybe NonPostings
plainNonPost :: Maybe NonPostings
}
deriving stock (PlainHighlight -> PlainHighlight -> Bool
(PlainHighlight -> PlainHighlight -> Bool)
-> (PlainHighlight -> PlainHighlight -> Bool) -> Eq PlainHighlight
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PlainHighlight -> PlainHighlight -> Bool
== :: PlainHighlight -> PlainHighlight -> Bool
$c/= :: PlainHighlight -> PlainHighlight -> Bool
/= :: PlainHighlight -> PlainHighlight -> Bool
Eq, Int -> PlainHighlight -> ShowS
[PlainHighlight] -> ShowS
PlainHighlight -> String
(Int -> PlainHighlight -> ShowS)
-> (PlainHighlight -> String)
-> ([PlainHighlight] -> ShowS)
-> Show PlainHighlight
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PlainHighlight -> ShowS
showsPrec :: Int -> PlainHighlight -> ShowS
$cshow :: PlainHighlight -> String
show :: PlainHighlight -> String
$cshowList :: [PlainHighlight] -> ShowS
showList :: [PlainHighlight] -> ShowS
Show)
data PostingsHighlight
= PostingsHighlight (Maybe CommonHighlight)
deriving stock (PostingsHighlight -> PostingsHighlight -> Bool
(PostingsHighlight -> PostingsHighlight -> Bool)
-> (PostingsHighlight -> PostingsHighlight -> Bool)
-> Eq PostingsHighlight
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PostingsHighlight -> PostingsHighlight -> Bool
== :: PostingsHighlight -> PostingsHighlight -> Bool
$c/= :: PostingsHighlight -> PostingsHighlight -> Bool
/= :: PostingsHighlight -> PostingsHighlight -> Bool
Eq, Int -> PostingsHighlight -> ShowS
[PostingsHighlight] -> ShowS
PostingsHighlight -> String
(Int -> PostingsHighlight -> ShowS)
-> (PostingsHighlight -> String)
-> ([PostingsHighlight] -> ShowS)
-> Show PostingsHighlight
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PostingsHighlight -> ShowS
showsPrec :: Int -> PostingsHighlight -> ShowS
$cshow :: PostingsHighlight -> String
show :: PostingsHighlight -> String
$cshowList :: [PostingsHighlight] -> ShowS
showList :: [PostingsHighlight] -> ShowS
Show)
data FastVectorHighlight = FastVectorHighlight
{ FastVectorHighlight -> Maybe CommonHighlight
fvCommon :: Maybe CommonHighlight,
FastVectorHighlight -> Maybe NonPostings
fvNonPostSettings :: Maybe NonPostings,
FastVectorHighlight -> Maybe Text
boundaryChars :: Maybe Text,
FastVectorHighlight -> Maybe Int
boundaryMaxScan :: Maybe Int,
FastVectorHighlight -> Maybe Int
fragmentOffset :: Maybe Int,
FastVectorHighlight -> [Text]
matchedFields :: [Text],
FastVectorHighlight -> Maybe Int
phraseLimit :: Maybe Int
}
deriving stock (FastVectorHighlight -> FastVectorHighlight -> Bool
(FastVectorHighlight -> FastVectorHighlight -> Bool)
-> (FastVectorHighlight -> FastVectorHighlight -> Bool)
-> Eq FastVectorHighlight
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FastVectorHighlight -> FastVectorHighlight -> Bool
== :: FastVectorHighlight -> FastVectorHighlight -> Bool
$c/= :: FastVectorHighlight -> FastVectorHighlight -> Bool
/= :: FastVectorHighlight -> FastVectorHighlight -> Bool
Eq, Int -> FastVectorHighlight -> ShowS
[FastVectorHighlight] -> ShowS
FastVectorHighlight -> String
(Int -> FastVectorHighlight -> ShowS)
-> (FastVectorHighlight -> String)
-> ([FastVectorHighlight] -> ShowS)
-> Show FastVectorHighlight
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FastVectorHighlight -> ShowS
showsPrec :: Int -> FastVectorHighlight -> ShowS
$cshow :: FastVectorHighlight -> String
show :: FastVectorHighlight -> String
$cshowList :: [FastVectorHighlight] -> ShowS
showList :: [FastVectorHighlight] -> ShowS
Show)
data CommonHighlight = CommonHighlight
{ CommonHighlight -> Maybe Text
order :: Maybe Text,
CommonHighlight -> Maybe Bool
forceSource :: Maybe Bool,
CommonHighlight -> Maybe HighlightTag
tag :: Maybe HighlightTag,
CommonHighlight -> Maybe HighlightEncoder
encoder :: Maybe HighlightEncoder,
CommonHighlight -> Maybe Int
noMatchSize :: Maybe Int,
CommonHighlight -> Maybe Query
highlightQuery :: Maybe Query,
CommonHighlight -> Maybe Bool
requireFieldMatch :: Maybe Bool
}
deriving stock (CommonHighlight -> CommonHighlight -> Bool
(CommonHighlight -> CommonHighlight -> Bool)
-> (CommonHighlight -> CommonHighlight -> Bool)
-> Eq CommonHighlight
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CommonHighlight -> CommonHighlight -> Bool
== :: CommonHighlight -> CommonHighlight -> Bool
$c/= :: CommonHighlight -> CommonHighlight -> Bool
/= :: CommonHighlight -> CommonHighlight -> Bool
Eq, Int -> CommonHighlight -> ShowS
[CommonHighlight] -> ShowS
CommonHighlight -> String
(Int -> CommonHighlight -> ShowS)
-> (CommonHighlight -> String)
-> ([CommonHighlight] -> ShowS)
-> Show CommonHighlight
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CommonHighlight -> ShowS
showsPrec :: Int -> CommonHighlight -> ShowS
$cshow :: CommonHighlight -> String
show :: CommonHighlight -> String
$cshowList :: [CommonHighlight] -> ShowS
showList :: [CommonHighlight] -> ShowS
Show)
data NonPostings = NonPostings
{ NonPostings -> Maybe Int
fragmentSize :: Maybe Int,
NonPostings -> Maybe Int
numberOfFragments :: Maybe Int
}
deriving stock (NonPostings -> NonPostings -> Bool
(NonPostings -> NonPostings -> Bool)
-> (NonPostings -> NonPostings -> Bool) -> Eq NonPostings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: NonPostings -> NonPostings -> Bool
== :: NonPostings -> NonPostings -> Bool
$c/= :: NonPostings -> NonPostings -> Bool
/= :: NonPostings -> NonPostings -> Bool
Eq, Int -> NonPostings -> ShowS
[NonPostings] -> ShowS
NonPostings -> String
(Int -> NonPostings -> ShowS)
-> (NonPostings -> String)
-> ([NonPostings] -> ShowS)
-> Show NonPostings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> NonPostings -> ShowS
showsPrec :: Int -> NonPostings -> ShowS
$cshow :: NonPostings -> String
show :: NonPostings -> String
$cshowList :: [NonPostings] -> ShowS
showList :: [NonPostings] -> ShowS
Show)
data HighlightEncoder
= DefaultEncoder
| HTMLEncoder
deriving stock (HighlightEncoder -> HighlightEncoder -> Bool
(HighlightEncoder -> HighlightEncoder -> Bool)
-> (HighlightEncoder -> HighlightEncoder -> Bool)
-> Eq HighlightEncoder
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HighlightEncoder -> HighlightEncoder -> Bool
== :: HighlightEncoder -> HighlightEncoder -> Bool
$c/= :: HighlightEncoder -> HighlightEncoder -> Bool
/= :: HighlightEncoder -> HighlightEncoder -> Bool
Eq, Int -> HighlightEncoder -> ShowS
[HighlightEncoder] -> ShowS
HighlightEncoder -> String
(Int -> HighlightEncoder -> ShowS)
-> (HighlightEncoder -> String)
-> ([HighlightEncoder] -> ShowS)
-> Show HighlightEncoder
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HighlightEncoder -> ShowS
showsPrec :: Int -> HighlightEncoder -> ShowS
$cshow :: HighlightEncoder -> String
show :: HighlightEncoder -> String
$cshowList :: [HighlightEncoder] -> ShowS
showList :: [HighlightEncoder] -> ShowS
Show)
instance ToJSON HighlightEncoder where
toJSON :: HighlightEncoder -> Value
toJSON HighlightEncoder
DefaultEncoder = Text -> Value
String Text
"default"
toJSON HighlightEncoder
HTMLEncoder = Text -> Value
String Text
"html"
data HighlightTag
= TagSchema Text
|
CustomTags ([Text], [Text])
deriving stock (HighlightTag -> HighlightTag -> Bool
(HighlightTag -> HighlightTag -> Bool)
-> (HighlightTag -> HighlightTag -> Bool) -> Eq HighlightTag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HighlightTag -> HighlightTag -> Bool
== :: HighlightTag -> HighlightTag -> Bool
$c/= :: HighlightTag -> HighlightTag -> Bool
/= :: HighlightTag -> HighlightTag -> Bool
Eq, Int -> HighlightTag -> ShowS
[HighlightTag] -> ShowS
HighlightTag -> String
(Int -> HighlightTag -> ShowS)
-> (HighlightTag -> String)
-> ([HighlightTag] -> ShowS)
-> Show HighlightTag
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HighlightTag -> ShowS
showsPrec :: Int -> HighlightTag -> ShowS
$cshow :: HighlightTag -> String
show :: HighlightTag -> String
$cshowList :: [HighlightTag] -> ShowS
showList :: [HighlightTag] -> ShowS
Show)
highlightSettingsPairs :: Maybe HighlightSettings -> [Pair]
highlightSettingsPairs :: Maybe HighlightSettings -> [Pair]
highlightSettingsPairs Maybe HighlightSettings
Nothing = []
highlightSettingsPairs (Just (Plain PlainHighlight
plh)) = Maybe PlainHighlight -> [Pair]
plainHighPairs (PlainHighlight -> Maybe PlainHighlight
forall a. a -> Maybe a
Just PlainHighlight
plh)
highlightSettingsPairs (Just (Postings PostingsHighlight
ph)) = Maybe PostingsHighlight -> [Pair]
postHighPairs (PostingsHighlight -> Maybe PostingsHighlight
forall a. a -> Maybe a
Just PostingsHighlight
ph)
highlightSettingsPairs (Just (FastVector FastVectorHighlight
fvh)) = Maybe FastVectorHighlight -> [Pair]
fastVectorHighPairs (FastVectorHighlight -> Maybe FastVectorHighlight
forall a. a -> Maybe a
Just FastVectorHighlight
fvh)
plainHighPairs :: Maybe PlainHighlight -> [Pair]
plainHighPairs :: Maybe PlainHighlight -> [Pair]
plainHighPairs Maybe PlainHighlight
Nothing = []
plainHighPairs (Just (PlainHighlight Maybe CommonHighlight
plCom Maybe NonPostings
plNonPost)) =
[Key
"type" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"plain"]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ Maybe CommonHighlight -> [Pair]
commonHighlightPairs Maybe CommonHighlight
plCom
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ Maybe NonPostings -> [Pair]
nonPostingsToPairs Maybe NonPostings
plNonPost
postHighPairs :: Maybe PostingsHighlight -> [Pair]
postHighPairs :: Maybe PostingsHighlight -> [Pair]
postHighPairs Maybe PostingsHighlight
Nothing = []
postHighPairs (Just (PostingsHighlight Maybe CommonHighlight
pCom)) =
(Key
"type" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"postings")
Pair -> [Pair] -> [Pair]
forall a. a -> [a] -> [a]
: Maybe CommonHighlight -> [Pair]
commonHighlightPairs Maybe CommonHighlight
pCom
fastVectorHighPairs :: Maybe FastVectorHighlight -> [Pair]
fastVectorHighPairs :: Maybe FastVectorHighlight -> [Pair]
fastVectorHighPairs Maybe FastVectorHighlight
Nothing = []
fastVectorHighPairs
( Just
( FastVectorHighlight
Maybe CommonHighlight
fvCom
Maybe NonPostings
fvNonPostSettings'
Maybe Text
fvBoundChars
Maybe Int
fvBoundMaxScan
Maybe Int
fvFragOff
[Text]
fvMatchedFields
Maybe Int
fvPhraseLim
)
) =
[ Key
"type" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"fvh",
Key
"boundary_chars" Key -> Maybe Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
fvBoundChars,
Key
"boundary_max_scan" Key -> Maybe Int -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Int
fvBoundMaxScan,
Key
"fragment_offset" Key -> Maybe Int -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Int
fvFragOff,
Key
"matched_fields" Key -> [Text] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Text]
fvMatchedFields,
Key
"phraseLimit" Key -> Maybe Int -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Int
fvPhraseLim
]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ Maybe CommonHighlight -> [Pair]
commonHighlightPairs Maybe CommonHighlight
fvCom
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ Maybe NonPostings -> [Pair]
nonPostingsToPairs Maybe NonPostings
fvNonPostSettings'
commonHighlightPairs :: Maybe CommonHighlight -> [Pair]
commonHighlightPairs :: Maybe CommonHighlight -> [Pair]
commonHighlightPairs Maybe CommonHighlight
Nothing = []
commonHighlightPairs
( Just
( CommonHighlight
Maybe Text
chScore
Maybe Bool
chForceSource
Maybe HighlightTag
chTag
Maybe HighlightEncoder
chEncoder
Maybe Int
chNoMatchSize
Maybe Query
chHighlightQuery
Maybe Bool
chRequireFieldMatch
)
) =
[ Key
"order" Key -> Maybe Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
chScore,
Key
"force_source" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
chForceSource,
Key
"encoder" Key -> Maybe HighlightEncoder -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe HighlightEncoder
chEncoder,
Key
"no_match_size" Key -> Maybe Int -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Int
chNoMatchSize,
Key
"highlight_query" Key -> Maybe Query -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Query
chHighlightQuery,
Key
"require_fieldMatch" Key -> Maybe Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Bool
chRequireFieldMatch
]
[Pair] -> [Pair] -> [Pair]
forall a. [a] -> [a] -> [a]
++ Maybe HighlightTag -> [Pair]
highlightTagToPairs Maybe HighlightTag
chTag
nonPostingsToPairs :: Maybe NonPostings -> [Pair]
nonPostingsToPairs :: Maybe NonPostings -> [Pair]
nonPostingsToPairs Maybe NonPostings
Nothing = []
nonPostingsToPairs (Just (NonPostings Maybe Int
npFragSize Maybe Int
npNumOfFrags)) =
[ Key
"fragment_size" Key -> Maybe Int -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Int
npFragSize,
Key
"number_of_fragments" Key -> Maybe Int -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe Int
npNumOfFrags
]
highlightTagToPairs :: Maybe HighlightTag -> [Pair]
highlightTagToPairs :: Maybe HighlightTag -> [Pair]
highlightTagToPairs (Just (TagSchema Text
_)) =
[ Key
"scheme" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
"default"
]
highlightTagToPairs (Just (CustomTags ([Text]
pre, [Text]
post))) =
[ Key
"pre_tags" Key -> [Text] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Text]
pre,
Key
"post_tags" Key -> [Text] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Text]
post
]
highlightTagToPairs Maybe HighlightTag
Nothing = []