@@ -505,6 +505,55 @@ data Search = Search { queryBody :: Maybe Query
505 , from :: From
505 , from :: From
506 , size :: Size } deriving (Eq, Show)
506 , size :: Size } deriving (Eq, Show)
508+data Highlights = Hightlights { globalsettings :: Maybe HighlightSettings
509+ , highlightFields :: [(FieldName, HighlightSettings)]
512+data HighlightSettings = Plain PlainHighlightSettings
513+ | Postings PostingsHighlightSettings
514+ | FastVector FastVectorHighlightSettings
516+data PlainHighlightSettings = PlainHighlightSettings { plainCommonSettings :: Maybe CommonHighlightSettings
517+ , plainNonPostSettings :: Maybe NonPostingsSettings }
519+ -- This requires that index_options are set to 'offset' in the mapping.
520+data PostingsHighlightSettings = PostingsHighlightSettings (Maybe CommonHighlightSettings)
522+-- This requires that term_vector is set to 'with_positions_offsets' in the mapping.
523+data FastVectorHighlightSettings = FastVectorHighlightSettings { boundaryChars :: Maybe Text
524+ , boundaryMaxScan :: Maybe Int
525+ , fragmentOffset :: Maybe Int
526+ , matchedFields :: [Text]
527+ , fvNonPostSettings :: Maybe NonPostingsSettings
528+ , phraseLimit :: Maybe Int
531+data CommonHighlightSettings = CommonHighlightSettings { highlightType :: Maybe HighlightType -- See below.
532+ , forceSource :: Maybe Bool
533+ , tagSettings :: Maybe HighlightTagSettings
534+ , encoder :: Maybe HighlightEncoder
535+ , noMatchSize :: Maybe Int
536+ , highlightQuery :: Maybe Query
537+ , requireFieldMatch :: Maybe Bool
539+-- Settings that are only applicable to FastVector and Plain highlighters.
540+data NonPostingsSettings = NonPostingsSettings { fragmentSize :: Maybe Int
541+ , numberOfFragments :: Maybe Int}
543+-- Used to force the type of highlighter used, if a different one is used on the mapping.
544+-- NOTE: Is there a way to ignore this, and just have it become part of the ToJSON instance
545+-- for the appropriate hightlight settings?
546+data HighlightType = PlainType
550+data HighlightEncoder = DefaultEncoder | HTMLEncoder
552+-- NOTE: Should the tags use some kind of HTML type, rather than Text?
553+data HighlightTagSettings = TagSchema Text
554+ | CustomTags ([Text], [Text]) -- Only uses more than the first value in the lists if fvh
508data Query =
557data Query =
509 TermQuery Term (Maybe Boost)
558 TermQuery Term (Maybe Boost)
510 | TermsQuery [Term] MinimumMatch
559 | TermsQuery [Term] MinimumMatch