git.iko.soy/typeable/bloodhound
on master help sign in
Skeleton types for highlights
commitc1720094348c0215ed82ab5db0cf8ae7ec3f9fda authorLiam Atkinson <liamatkinson@gmail.com> dateThu 16 Oct 2014, 21:53 (12 years ago) parentffae1ce
1 file changed+49
Database/Bloodhound/Types.hs+49
Database/Bloodhound/Types.hs+49
@@ -505,6 +505,55 @@ data Search = Search { queryBody :: Maybe Query
505505 , from :: From
506506 , size :: Size } deriving (Eq, Show)
507507
508+data Highlights = Hightlights { globalsettings :: Maybe HighlightSettings
509+ , highlightFields :: [(FieldName, HighlightSettings)]
510+ }
511+
512+data HighlightSettings = Plain PlainHighlightSettings
513+ | Postings PostingsHighlightSettings
514+ | FastVector FastVectorHighlightSettings
515+
516+data PlainHighlightSettings = PlainHighlightSettings { plainCommonSettings :: Maybe CommonHighlightSettings
517+ , plainNonPostSettings :: Maybe NonPostingsSettings }
518+
519+ -- This requires that index_options are set to 'offset' in the mapping.
520+data PostingsHighlightSettings = PostingsHighlightSettings (Maybe CommonHighlightSettings)
521+
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
529+ }
530+
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
538+ }
539+-- Settings that are only applicable to FastVector and Plain highlighters.
540+data NonPostingsSettings = NonPostingsSettings { fragmentSize :: Maybe Int
541+ , numberOfFragments :: Maybe Int}
542+
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
547+ | PostingsType
548+ | FastVectorType
549+
550+data HighlightEncoder = DefaultEncoder | HTMLEncoder
551+
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
555+
556+
508557data Query =
509558 TermQuery Term (Maybe Boost)
510559 | TermsQuery [Term] MinimumMatch