@@ -368,7 +368,7 @@ data Status = Status { ok :: Maybe Bool
368368 , status :: Int
369369 , name :: Text
370370 , version :: Version
371− , tagline :: Text } deriving (Eq, Show)
371+ , tagline :: Text } deriving (Eq, Show, Generic)
372372
373373{-| 'IndexSettings' is used to configure the shards and replicas when you create
374374 an Elasticsearch Index.
@@ -378,7 +378,7 @@ data Status = Status { ok :: Maybe Bool
378378
379379data IndexSettings =
380380 IndexSettings { indexShards :: ShardCount
381− , indexReplicas :: ReplicaCount } deriving (Eq, Show)
381+ , indexReplicas :: ReplicaCount } deriving (Eq, Show, Generic)
382382
383383{-| 'defaultIndexSettings' is an 'IndexSettings' with 3 shards and 2 replicas. -}
384384defaultIndexSettings :: IndexSettings
@@ -436,7 +436,7 @@ data UpdatableIndexSetting = NumberOfReplicas ReplicaCount
436436 | IndexCompoundFormat CompoundFormat
437437 | IndexCompoundOnFlush Bool
438438 | WarmerEnabled Bool
439− deriving (Eq, Show)
439+ deriving (Eq, Show, Generic)
440440
441441data AllocationPolicy = AllocAll
442442 -- ^ Allows shard allocation for all shards.
@@ -446,42 +446,42 @@ data AllocationPolicy = AllocAll
446446 -- ^ Allows shard allocation only for primary shards for new indices.
447447 | AllocNone
448448 -- ^ No shard allocation is allowed
449− deriving (Eq, Show)
449+ deriving (Eq, Show, Generic)
450450
451451data ReplicaBounds = ReplicasBounded Int Int
452452 | ReplicasLowerBounded Int
453453 | ReplicasUnbounded
454− deriving (Eq, Show)
454+ deriving (Eq, Show, Generic)
455455
456−newtype Bytes = Bytes Int deriving (Eq, Show, Ord, ToJSON, FromJSON)
456+newtype Bytes = Bytes Int deriving (Eq, Show, Generic, Ord, ToJSON, FromJSON)
457457
458458data FSType = FSSimple
459− | FSBuffered deriving (Eq, Show, Ord)
459+ | FSBuffered deriving (Eq, Show, Generic, Ord)
460460
461461data InitialShardCount = QuorumShards
462462 | QuorumMinus1Shards
463463 | FullShards
464464 | FullMinus1Shards
465465 | ExplicitShards Int
466− deriving (Eq, Show)
466+ deriving (Eq, Show, Generic)
467467
468468data NodeAttrFilter = NodeAttrFilter { nodeAttrFilterName :: NodeAttrName
469469 , nodeAttrFilterValues :: NonEmpty Text}
470− deriving (Eq, Show)
470+ deriving (Eq, Show, Generic, Ord)
471471
472−newtype NodeAttrName = NodeAttrName Text deriving (Eq, Show)
472+newtype NodeAttrName = NodeAttrName Text deriving (Eq, Show, Ord, Generic)
473473
474474data CompoundFormat = CompoundFileFormat Bool
475475 | MergeSegmentVsTotalIndex Double
476476 -- ^ percentage between 0 and 1 where 0 is false, 1 is true
477− deriving (Eq, Show)
477+ deriving (Eq, Show, Generic)
478478
479479newtype NominalDiffTimeJSON = NominalDiffTimeJSON { ndtJSON :: NominalDiffTime }
480480
481481data IndexSettingsSummary = IndexSettingsSummary { sSummaryIndexName :: IndexName
482482 , sSummaryFixedSettings :: IndexSettings
483483 , sSummaryUpdateable :: [UpdatableIndexSetting]}
484− deriving (Eq, Show)
484+ deriving (Eq, Show, Generic)
485485
486486{-| 'Reply' and 'Method' are type synonyms from 'Network.HTTP.Types.Method.Method' -}
487487type Reply = Network.HTTP.Client.Response L.ByteString
@@ -491,7 +491,7 @@ type Method = NHTM.Method
491491
492492 <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-open-close.html>
493493-}
494−data OpenCloseIndex = OpenIndex | CloseIndex deriving (Eq, Show)
494+data OpenCloseIndex = OpenIndex | CloseIndex deriving (Eq, Show, Generic)
495495
496496data FieldType = GeoPointType
497497 | GeoShapeType
@@ -499,10 +499,10 @@ data FieldType = GeoPointType
499499 | IntegerType
500500 | LongType
501501 | ShortType
502− | ByteType deriving (Eq, Show)
502+ | ByteType deriving (Eq, Show, Generic)
503503
504504data FieldDefinition =
505− FieldDefinition { fieldType :: FieldType } deriving (Eq, Show)
505+ FieldDefinition { fieldType :: FieldType } deriving (Eq, Show, Generic)
506506
507507{-| An 'IndexTemplate' defines a template that will automatically be
508508 applied to new indices created. The templates include both
@@ -520,7 +520,7 @@ data IndexTemplate =
520520
521521data MappingField =
522522 MappingField { mappingFieldName :: FieldName
523− , fieldDefinition :: FieldDefinition } deriving (Eq, Show)
523+ , fieldDefinition :: FieldDefinition } deriving (Eq, Show, Generic)
524524
525525{-| Support for type reification of 'Mapping's is currently incomplete, for
526526 now the mapping API verbiage expects a 'ToJSON'able blob.
@@ -530,7 +530,7 @@ data MappingField =
530530 and keeping different kinds of documents separated if possible.
531531-}
532532data Mapping = Mapping { typeName :: TypeName
533− , mappingFields :: [MappingField] } deriving (Eq, Show)
533+ , mappingFields :: [MappingField] } deriving (Eq, Show, Generic)
534534
535535{-| 'BulkOperation' is a sum type for expressing the four kinds of bulk
536536 operation index, create, delete, and update. 'BulkIndex' behaves like an
@@ -542,7 +542,7 @@ data BulkOperation =
542542 BulkIndex IndexName MappingName DocId Value
543543 | BulkCreate IndexName MappingName DocId Value
544544 | BulkDelete IndexName MappingName DocId
545− | BulkUpdate IndexName MappingName DocId Value deriving (Eq, Show)
545+ | BulkUpdate IndexName MappingName DocId Value deriving (Eq, Show, Generic)
546546
547547{-| 'EsResult' describes the standard wrapper JSON document that you see in
548548 successful Elasticsearch lookups or lookups that couldn't find the document.
@@ -550,55 +550,55 @@ data BulkOperation =
550550data EsResult a = EsResult { _index :: Text
551551 , _type :: Text
552552 , _id :: Text
553− , foundResult :: Maybe (EsResultFound a)} deriving (Eq, Show)
553+ , foundResult :: Maybe (EsResultFound a)} deriving (Eq, Show, Generic)
554554
555555{-| 'EsResultFound' contains the document and its metadata inside of an
556556 'EsResult' when the document was successfully found.
557557-}
558558data EsResultFound a = EsResultFound { _version :: DocVersion
559− , _source :: a } deriving (Eq, Show)
559+ , _source :: a } deriving (Eq, Show, Generic)
560560
561561{-| 'EsError' is the generic type that will be returned when there was a
562562 problem. If you can't parse the expected response, its a good idea to
563563 try parsing this.
564564-}
565565data EsError = EsError { errorStatus :: Int
566− , errorMessage :: Text } deriving (Eq, Show)
566+ , errorMessage :: Text } deriving (Eq, Show, Generic)
567567
568568data IndexAlias = IndexAlias { srcIndex :: IndexName
569− , indexAlias :: IndexAliasName } deriving (Eq, Show)
569+ , indexAlias :: IndexAliasName } deriving (Eq, Show, Generic)
570570
571−newtype IndexAliasName = IndexAliasName { indexAliasName :: IndexName } deriving (Eq, Show, ToJSON)
571+newtype IndexAliasName = IndexAliasName { indexAliasName :: IndexName } deriving (Eq, Show, Generic, ToJSON)
572572
573573data IndexAliasAction = AddAlias IndexAlias IndexAliasCreate
574− | RemoveAlias IndexAlias deriving (Show, Eq, Typeable)
574+ | RemoveAlias IndexAlias deriving (Show, Eq, Generic, Typeable)
575575
576576data IndexAliasCreate = IndexAliasCreate { aliasCreateRouting :: Maybe AliasRouting
577577 , aliasCreateFilter :: Maybe Filter}
578− deriving (Show, Eq, Typeable)
578+ deriving (Show, Eq, Generic, Typeable)
579579
580580data AliasRouting = AllAliasRouting RoutingValue
581581 | GranularAliasRouting (Maybe SearchAliasRouting) (Maybe IndexAliasRouting)
582− deriving (Show, Eq, Typeable)
582+ deriving (Show, Eq, Generic, Typeable)
583583
584−newtype SearchAliasRouting = SearchAliasRouting (NonEmpty RoutingValue) deriving (Show, Eq, Typeable)
584+newtype SearchAliasRouting = SearchAliasRouting (NonEmpty RoutingValue) deriving (Show, Eq, Generic, Typeable)
585585
586−newtype IndexAliasRouting = IndexAliasRouting RoutingValue deriving (Show, Eq, ToJSON, FromJSON, Typeable)
586+newtype IndexAliasRouting = IndexAliasRouting RoutingValue deriving (Show, Eq, Generic, ToJSON, FromJSON, Typeable)
587587
588−newtype RoutingValue = RoutingValue { routingValue :: Text } deriving (Show, Eq, ToJSON, FromJSON, Typeable)
588+newtype RoutingValue = RoutingValue { routingValue :: Text } deriving (Show, Eq, Generic, ToJSON, FromJSON, Typeable)
589589
590−newtype IndexAliasesSummary = IndexAliasesSummary { indexAliasesSummary :: [IndexAliasSummary] } deriving (Show, Eq, Typeable)
590+newtype IndexAliasesSummary = IndexAliasesSummary { indexAliasesSummary :: [IndexAliasSummary] } deriving (Show, Eq, Generic, Typeable)
591591
592592{-| 'IndexAliasSummary' is a summary of an index alias configured for a server. -}
593593data IndexAliasSummary = IndexAliasSummary { indexAliasSummaryAlias :: IndexAlias
594− , indexAliasSummaryCreate :: IndexAliasCreate} deriving (Show, Eq)
594+ , indexAliasSummaryCreate :: IndexAliasCreate} deriving (Show, Eq, Generic)
595595
596596{-| 'DocVersion' is an integer version number for a document between 1
597597and 9.2e+18 used for <<https://www.elastic.co/guide/en/elasticsearch/guide/current/optimistic-concurrency-control.html optimistic concurrency control>>.
598598-}
599599newtype DocVersion = DocVersion {
600600 docVersionNumber :: Int
601− } deriving (Eq, Show, Ord, ToJSON)
601+ } deriving (Eq, Show, Generic, Ord, ToJSON)
602602
603603-- | Smart constructor for in-range doc version
604604mkDocVersion :: Int -> Maybe DocVersion
@@ -612,7 +612,7 @@ mkDocVersion i
612612own version numbers instead of ones from ES.
613613-}
614614newtype ExternalDocVersion = ExternalDocVersion DocVersion
615− deriving (Eq, Show, Ord, Bounded, Enum, ToJSON)
615+ deriving (Eq, Show, Generic, Ord, Bounded, Enum, ToJSON)
616616
617617{-| 'VersionControl' is specified when indexing documents as a
618618optimistic concurrency control.
@@ -646,12 +646,12 @@ data VersionControl = NoVersionControl
646646 -- given version will be the new version. This is
647647 -- typically used for correcting errors. Use with
648648 -- care, as this could result in data loss.
649− deriving (Show, Eq, Ord)
649+ deriving (Show, Eq, Generic, Ord)
650650
651651{-| 'DocumentParent' is used to specify a parent document.
652652-}
653653newtype DocumentParent = DocumentParent DocId
654− deriving (Eq, Show)
654+ deriving (Eq, Show, Generic)
655655
656656{-| 'IndexDocumentSettings' are special settings supplied when indexing
657657a document. For the best backwards compatiblity when new fields are
@@ -660,7 +660,7 @@ added, you should probably prefer to start with 'defaultIndexDocumentSettings'
660660data IndexDocumentSettings =
661661 IndexDocumentSettings { idsVersionControl :: VersionControl
662662 , idsParent :: Maybe DocumentParent
663− } deriving (Eq, Show)
663+ } deriving (Eq, Show, Generic)
664664
665665{-| Reasonable default settings. Chooses no version control and no parent.
666666-}
@@ -680,7 +680,7 @@ type Sort = [SortSpec]
680680<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#search-request-sort>
681681-}
682682data SortSpec = DefaultSortSpec DefaultSort
683− | GeoDistanceSortSpec SortOrder GeoPoint DistanceUnit deriving (Eq, Show)
683+ | GeoDistanceSortSpec SortOrder GeoPoint DistanceUnit deriving (Eq, Show, Generic)
684684
685685{-| 'DefaultSort' is usually the kind of 'SortSpec' you'll want. There's a
686686 'mkSort' convenience function for when you want to specify only the most
@@ -695,7 +695,7 @@ data DefaultSort =
695695 , ignoreUnmapped :: Bool
696696 , sortMode :: Maybe SortMode
697697 , missingSort :: Maybe Missing
698− , nestedFilter :: Maybe Filter } deriving (Eq, Show)
698+ , nestedFilter :: Maybe Filter } deriving (Eq, Show, Generic)
699699
700700{-| 'SortOrder' is 'Ascending' or 'Descending', as you might expect. These get
701701 encoded into "asc" or "desc" when turned into JSON.
@@ -703,7 +703,7 @@ data DefaultSort =
703703<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#search-request-sort>
704704-}
705705data SortOrder = Ascending
706− | Descending deriving (Eq, Show)
706+ | Descending deriving (Eq, Show, Generic)
707707
708708{-| 'Missing' prescribes how to handle missing fields. A missing field can be
709709 sorted last, first, or using a custom value as a substitute.
@@ -712,7 +712,7 @@ data SortOrder = Ascending
712712-}
713713data Missing = LastMissing
714714 | FirstMissing
715− | CustomMissing Text deriving (Eq, Show)
715+ | CustomMissing Text deriving (Eq, Show, Generic)
716716
717717{-| 'SortMode' prescribes how to handle sorting array/multi-valued fields.
718718
@@ -721,7 +721,7 @@ http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-req
721721data SortMode = SortMin
722722 | SortMax
723723 | SortSum
724− | SortAvg deriving (Eq, Show)
724+ | SortAvg deriving (Eq, Show, Generic)
725725
726726{-| 'mkSort' defaults everything but the 'FieldName' and the 'SortOrder' so
727727 that you can concisely describe the usual kind of 'SortSpec's you want.
@@ -743,19 +743,19 @@ type PrefixValue = Text
743743{-| 'BooleanOperator' is the usual And/Or operators with an ES compatible
744744 JSON encoding baked in. Used all over the place.
745745-}
746−data BooleanOperator = And | Or deriving (Eq, Show, Typeable)
746+data BooleanOperator = And | Or deriving (Eq, Show, Generic, Typeable)
747747
748748{-| 'ShardCount' is part of 'IndexSettings'
749749-}
750−newtype ShardCount = ShardCount Int deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
750+newtype ShardCount = ShardCount Int deriving (Eq, Show, Generic, ToJSON, Typeable)
751751
752752{-| 'ReplicaCount' is part of 'IndexSettings'
753753-}
754−newtype ReplicaCount = ReplicaCount Int deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
754+newtype ReplicaCount = ReplicaCount Int deriving (Eq, Show, Generic, ToJSON, Typeable)
755755
756756{-| 'Server' is used with the client functions to point at the ES instance
757757-}
758−newtype Server = Server Text deriving (Eq, Show)
758+newtype Server = Server Text deriving (Eq, Show, Generic)
759759
760760{-| 'IndexName' is used to describe which index to query/create/delete
761761-}
@@ -787,27 +787,27 @@ newtype QueryString = QueryString Text deriving (Eq, Generic, Show, ToJSON, From
787787{-| 'FieldName' is used all over the place wherever a specific field within
788788 a document needs to be specified, usually in 'Query's or 'Filter's.
789789-}
790−newtype FieldName = FieldName Text deriving (Eq, Show, ToJSON, FromJSON, Typeable)
790+newtype FieldName = FieldName Text deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
791791
792792
793793{-| 'Script' is often used in place of 'FieldName' to specify more
794794complex ways of extracting a value from a document.
795795-}
796−newtype Script = Script { scriptText :: Text } deriving (Eq, Show)
796+newtype Script = Script { scriptText :: Text } deriving (Eq, Show, Generic)
797797
798798{-| 'CacheName' is used in 'RegexpFilter' for describing the
799799 'CacheKey' keyed caching behavior.
800800-}
801−newtype CacheName = CacheName Text deriving (Eq, Show, ToJSON, FromJSON, Typeable)
801+newtype CacheName = CacheName Text deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
802802
803803{-| 'CacheKey' is used in 'RegexpFilter' to key regex caching.
804804-}
805805newtype CacheKey =
806− CacheKey Text deriving (Eq, Show, ToJSON, FromJSON, Typeable)
806+ CacheKey Text deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
807807newtype Existence =
808− Existence Bool deriving (Eq, Show, ToJSON, FromJSON, Typeable)
808+ Existence Bool deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
809809newtype NullValue =
810− NullValue Bool deriving (Eq, Show, ToJSON, FromJSON, Typeable)
810+ NullValue Bool deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
811811newtype CutoffFrequency =
812812 CutoffFrequency Double deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
813813newtype Analyzer =
@@ -900,8 +900,8 @@ unpackId :: DocId -> Text
900900unpackId (DocId docId) = docId
901901
902902type TrackSortScores = Bool
903−newtype From = From Int deriving (Eq, Show, ToJSON)
904−newtype Size = Size Int deriving (Eq, Show, ToJSON)
903+newtype From = From Int deriving (Eq, Show, Generic, ToJSON)
904+newtype Size = Size Int deriving (Eq, Show, Generic, ToJSON)
905905
906906data Search = Search { queryBody :: Maybe Query
907907 , filterBody :: Maybe Filter
@@ -914,7 +914,7 @@ data Search = Search { queryBody :: Maybe Query
914914 , size :: Size
915915 , searchType :: SearchType
916916 , fields :: Maybe [FieldName]
917− , source :: Maybe Source } deriving (Eq, Show)
917+ , source :: Maybe Source } deriving (Eq, Show, Generic)
918918
919919data SearchType = SearchTypeQueryThenFetch
920920 | SearchTypeDfsQueryThenFetch
@@ -922,40 +922,40 @@ data SearchType = SearchTypeQueryThenFetch
922922 | SearchTypeScan
923923 | SearchTypeQueryAndFetch
924924 | SearchTypeDfsQueryAndFetch
925− deriving (Eq, Show)
925+ deriving (Eq, Show, Generic)
926926
927927data Source =
928928 NoSource
929929 | SourcePatterns PatternOrPatterns
930930 | SourceIncludeExclude Include Exclude
931− deriving (Show, Eq)
931+ deriving (Show, Eq, Generic)
932932
933933data PatternOrPatterns = PopPattern Pattern
934− | PopPatterns [Pattern] deriving (Eq, Show)
934+ | PopPatterns [Pattern] deriving (Eq, Show, Generic)
935935
936−data Include = Include [Pattern] deriving (Eq, Show)
937−data Exclude = Exclude [Pattern] deriving (Eq, Show)
936+data Include = Include [Pattern] deriving (Eq, Show, Generic)
937+data Exclude = Exclude [Pattern] deriving (Eq, Show, Generic)
938938
939−newtype Pattern = Pattern Text deriving (Eq, Show)
939+newtype Pattern = Pattern Text deriving (Eq, Show, Generic)
940940
941941data Highlights = Highlights { globalsettings :: Maybe HighlightSettings
942942 , highlightFields :: [FieldHighlight]
943− } deriving (Show, Eq)
943+ } deriving (Show, Eq, Generic)
944944
945945data FieldHighlight = FieldHighlight FieldName (Maybe HighlightSettings)
946− deriving (Show, Eq)
946+ deriving (Show, Eq, Generic)
947947
948948
949949data HighlightSettings = Plain PlainHighlight
950950 | Postings PostingsHighlight
951951 | FastVector FastVectorHighlight
952− deriving (Show, Eq)
952+ deriving (Show, Eq, Generic)
953953data PlainHighlight =
954954 PlainHighlight { plainCommon :: Maybe CommonHighlight
955− , plainNonPost :: Maybe NonPostings } deriving (Show, Eq)
955+ , plainNonPost :: Maybe NonPostings } deriving (Show, Eq, Generic)
956956
957957 -- This requires that index_options are set to 'offset' in the mapping.
958−data PostingsHighlight = PostingsHighlight (Maybe CommonHighlight) deriving (Show, Eq)
958+data PostingsHighlight = PostingsHighlight (Maybe CommonHighlight) deriving (Show, Eq, Generic)
959959
960960-- This requires that term_vector is set to 'with_positions_offsets' in the mapping.
961961data FastVectorHighlight =
@@ -966,7 +966,7 @@ data FastVectorHighlight =
966966 , fragmentOffset :: Maybe Int
967967 , matchedFields :: [Text]
968968 , phraseLimit :: Maybe Int
969− } deriving (Show, Eq)
969+ } deriving (Show, Eq, Generic)
970970
971971data CommonHighlight =
972972 CommonHighlight { order :: Maybe Text
@@ -976,21 +976,21 @@ data CommonHighlight =
976976 , noMatchSize :: Maybe Int
977977 , highlightQuery :: Maybe Query
978978 , requireFieldMatch :: Maybe Bool
979− } deriving (Show, Eq)
979+ } deriving (Show, Eq, Generic)
980980
981981-- Settings that are only applicable to FastVector and Plain highlighters.
982982data NonPostings =
983983 NonPostings { fragmentSize :: Maybe Int
984− , numberOfFragments :: Maybe Int} deriving (Show, Eq)
984+ , numberOfFragments :: Maybe Int} deriving (Show, Eq, Generic)
985985
986986data HighlightEncoder = DefaultEncoder
987987 | HTMLEncoder
988− deriving (Show, Eq)
988+ deriving (Show, Eq, Generic)
989989
990990-- NOTE: Should the tags use some kind of HTML type, rather than Text?
991991data HighlightTag = TagSchema Text
992992 | CustomTags ([Text], [Text]) -- Only uses more than the first value in the lists if fvh
993− deriving (Show, Eq)
993+ deriving (Show, Eq, Generic)
994994
995995
996996data Query =
@@ -1021,19 +1021,19 @@ data Query =
10211021 | QuerySimpleQueryStringQuery SimpleQueryStringQuery
10221022 | QueryRangeQuery RangeQuery
10231023 | QueryRegexpQuery RegexpQuery
1024− deriving (Eq, Show, Typeable)
1024+ deriving (Eq, Show, Generic, Typeable)
10251025
10261026data RegexpQuery =
10271027 RegexpQuery { regexpQueryField :: FieldName
10281028 , regexpQuery :: Regexp
10291029 , regexpQueryFlags :: RegexpFlags
10301030 , regexpQueryBoost :: Maybe Boost
1031− } deriving (Eq, Show, Typeable)
1031+ } deriving (Eq, Show, Generic, Typeable)
10321032
10331033data RangeQuery =
10341034 RangeQuery { rangeQueryField :: FieldName
10351035 , rangeQueryRange :: RangeValue
1036− , rangeQueryBoost :: Boost } deriving (Eq, Show, Typeable)
1036+ , rangeQueryBoost :: Boost } deriving (Eq, Show, Generic, Typeable)
10371037
10381038mkRangeQuery :: FieldName -> RangeValue -> RangeQuery
10391039mkRangeQuery f r = RangeQuery f r (Boost 1.0)
@@ -1047,7 +1047,7 @@ data SimpleQueryStringQuery =
10471047 , simpleQueryStringFlags :: Maybe (NonEmpty SimpleQueryFlag)
10481048 , simpleQueryStringLowercaseExpanded :: Maybe LowercaseExpanded
10491049 , simpleQueryStringLocale :: Maybe Locale
1050− } deriving (Eq, Show, Typeable)
1050+ } deriving (Eq, Show, Generic, Typeable)
10511051
10521052data SimpleQueryFlag =
10531053 SimpleQueryAll
@@ -1061,7 +1061,7 @@ data SimpleQueryFlag =
10611061 | SimpleQueryWhitespace
10621062 | SimpleQueryFuzzy
10631063 | SimpleQueryNear
1064− | SimpleQuerySlop deriving (Eq, Show, Typeable)
1064+ | SimpleQuerySlop deriving (Eq, Show, Generic, Typeable)
10651065
10661066-- use_dis_max and tie_breaker when fields are plural?
10671067data QueryStringQuery =
@@ -1083,7 +1083,7 @@ data QueryStringQuery =
10831083 , queryStringMinimumShouldMatch :: Maybe MinimumMatch
10841084 , queryStringLenient :: Maybe Lenient
10851085 , queryStringLocale :: Maybe Locale
1086− } deriving (Eq, Show, Typeable)
1086+ } deriving (Eq, Show, Generic, Typeable)
10871087
10881088mkQueryStringQuery :: QueryString -> QueryStringQuery
10891089mkQueryStringQuery qs =
@@ -1094,19 +1094,19 @@ mkQueryStringQuery qs =
10941094 Nothing Nothing
10951095
10961096data FieldOrFields = FofField FieldName
1097− | FofFields (NonEmpty FieldName) deriving (Eq, Show, Typeable)
1097+ | FofFields (NonEmpty FieldName) deriving (Eq, Show, Generic, Typeable)
10981098
10991099data PrefixQuery =
11001100 PrefixQuery
11011101 { prefixQueryField :: FieldName
11021102 , prefixQueryPrefixValue :: Text
1103− , prefixQueryBoost :: Maybe Boost } deriving (Eq, Show, Typeable)
1103+ , prefixQueryBoost :: Maybe Boost } deriving (Eq, Show, Generic, Typeable)
11041104
11051105data NestedQuery =
11061106 NestedQuery
11071107 { nestedQueryPath :: QueryPath
11081108 , nestedQueryScoreType :: ScoreType
1109− , nestedQuery :: Query } deriving (Eq, Show, Typeable)
1109+ , nestedQuery :: Query } deriving (Eq, Show, Generic, Typeable)
11101110
11111111data MoreLikeThisFieldQuery =
11121112 MoreLikeThisFieldQuery
@@ -1124,7 +1124,7 @@ data MoreLikeThisFieldQuery =
11241124 , moreLikeThisFieldBoostTerms :: Maybe BoostTerms
11251125 , moreLikeThisFieldBoost :: Maybe Boost
11261126 , moreLikeThisFieldAnalyzer :: Maybe Analyzer
1127− } deriving (Eq, Show, Typeable)
1127+ } deriving (Eq, Show, Generic, Typeable)
11281128
11291129data MoreLikeThisQuery =
11301130 MoreLikeThisQuery
@@ -1142,32 +1142,32 @@ data MoreLikeThisQuery =
11421142 , moreLikeThisBoostTerms :: Maybe BoostTerms
11431143 , moreLikeThisBoost :: Maybe Boost
11441144 , moreLikeThisAnalyzer :: Maybe Analyzer
1145− } deriving (Eq, Show, Typeable)
1145+ } deriving (Eq, Show, Generic, Typeable)
11461146
11471147data IndicesQuery =
11481148 IndicesQuery
11491149 { indicesQueryIndices :: [IndexName]
11501150 , indicesQuery :: Query
11511151 -- default "all"
1152− , indicesQueryNoMatch :: Maybe Query } deriving (Eq, Show, Typeable)
1152+ , indicesQueryNoMatch :: Maybe Query } deriving (Eq, Show, Generic, Typeable)
11531153
11541154data HasParentQuery =
11551155 HasParentQuery
11561156 { hasParentQueryType :: TypeName
11571157 , hasParentQuery :: Query
1158− , hasParentQueryScoreType :: Maybe ScoreType } deriving (Eq, Show, Typeable)
1158+ , hasParentQueryScoreType :: Maybe ScoreType } deriving (Eq, Show, Generic, Typeable)
11591159
11601160data HasChildQuery =
11611161 HasChildQuery
11621162 { hasChildQueryType :: TypeName
11631163 , hasChildQuery :: Query
1164− , hasChildQueryScoreType :: Maybe ScoreType } deriving (Eq, Show, Typeable)
1164+ , hasChildQueryScoreType :: Maybe ScoreType } deriving (Eq, Show, Generic, Typeable)
11651165
11661166data ScoreType =
11671167 ScoreTypeMax
11681168 | ScoreTypeSum
11691169 | ScoreTypeAvg
1170− | ScoreTypeNone deriving (Eq, Show, Typeable)
1170+ | ScoreTypeNone deriving (Eq, Show, Generic, Typeable)
11711171
11721172data FuzzyQuery =
11731173 FuzzyQuery { fuzzyQueryField :: FieldName
@@ -1176,7 +1176,7 @@ data FuzzyQuery =
11761176 , fuzzyQueryMaxExpansions :: MaxExpansions
11771177 , fuzzyQueryFuzziness :: Fuzziness
11781178 , fuzzyQueryBoost :: Maybe Boost
1179− } deriving (Eq, Show, Typeable)
1179+ } deriving (Eq, Show, Generic, Typeable)
11801180
11811181data FuzzyLikeFieldQuery =
11821182 FuzzyLikeFieldQuery
@@ -1189,7 +1189,7 @@ data FuzzyLikeFieldQuery =
11891189 , fuzzyLikeFieldPrefixLength :: PrefixLength
11901190 , fuzzyLikeFieldBoost :: Boost
11911191 , fuzzyLikeFieldAnalyzer :: Maybe Analyzer
1192− } deriving (Eq, Show, Typeable)
1192+ } deriving (Eq, Show, Generic, Typeable)
11931193
11941194data FuzzyLikeThisQuery =
11951195 FuzzyLikeThisQuery
@@ -1201,19 +1201,19 @@ data FuzzyLikeThisQuery =
12011201 , fuzzyLikePrefixLength :: PrefixLength
12021202 , fuzzyLikeBoost :: Boost
12031203 , fuzzyLikeAnalyzer :: Maybe Analyzer
1204− } deriving (Eq, Show, Typeable)
1204+ } deriving (Eq, Show, Generic, Typeable)
12051205
12061206data FilteredQuery =
12071207 FilteredQuery
12081208 { filteredQuery :: Query
1209− , filteredFilter :: Filter } deriving (Eq, Show, Typeable)
1209+ , filteredFilter :: Filter } deriving (Eq, Show, Generic, Typeable)
12101210
12111211data DisMaxQuery =
12121212 DisMaxQuery { disMaxQueries :: [Query]
12131213 -- default 0.0
12141214 , disMaxTiebreaker :: Tiebreaker
12151215 , disMaxBoost :: Maybe Boost
1216− } deriving (Eq, Show, Typeable)
1216+ } deriving (Eq, Show, Generic, Typeable)
12171217
12181218data MatchQuery =
12191219 MatchQuery { matchQueryField :: FieldName
@@ -1225,7 +1225,7 @@ data MatchQuery =
12251225 , matchQueryAnalyzer :: Maybe Analyzer
12261226 , matchQueryMaxExpansions :: Maybe MaxExpansions
12271227 , matchQueryLenient :: Maybe Lenient
1228− , matchQueryBoost :: Maybe Boost } deriving (Eq, Show, Typeable)
1228+ , matchQueryBoost :: Maybe Boost } deriving (Eq, Show, Generic, Typeable)
12291229
12301230{-| 'mkMatchQuery' is a convenience function that defaults the less common parameters,
12311231 enabling you to provide only the 'FieldName' and 'QueryString' to make a 'MatchQuery'
@@ -1235,7 +1235,7 @@ mkMatchQuery field query = MatchQuery field query Or ZeroTermsNone Nothing Nothi
12351235
12361236data MatchQueryType =
12371237 MatchPhrase
1238− | MatchPhrasePrefix deriving (Eq, Show, Typeable)
1238+ | MatchPhrasePrefix deriving (Eq, Show, Generic, Typeable)
12391239
12401240data MultiMatchQuery =
12411241 MultiMatchQuery { multiMatchQueryFields :: [FieldName]
@@ -1247,7 +1247,7 @@ data MultiMatchQuery =
12471247 , multiMatchQueryCutoffFrequency :: Maybe CutoffFrequency
12481248 , multiMatchQueryAnalyzer :: Maybe Analyzer
12491249 , multiMatchQueryMaxExpansions :: Maybe MaxExpansions
1250− , multiMatchQueryLenient :: Maybe Lenient } deriving (Eq, Show, Typeable)
1250+ , multiMatchQueryLenient :: Maybe Lenient } deriving (Eq, Show, Generic, Typeable)
12511251
12521252{-| 'mkMultiMatchQuery' is a convenience function that defaults the less common parameters,
12531253 enabling you to provide only the list of 'FieldName's and 'QueryString' to
@@ -1264,7 +1264,7 @@ data MultiMatchQueryType =
12641264 | MultiMatchMostFields
12651265 | MultiMatchCrossFields
12661266 | MultiMatchPhrase
1267− | MultiMatchPhrasePrefix deriving (Eq, Show, Typeable)
1267+ | MultiMatchPhrasePrefix deriving (Eq, Show, Generic, Typeable)
12681268
12691269data BoolQuery =
12701270 BoolQuery { boolQueryMustMatch :: [Query]
@@ -1273,7 +1273,7 @@ data BoolQuery =
12731273 , boolQueryMinimumShouldMatch :: Maybe MinimumMatch
12741274 , boolQueryBoost :: Maybe Boost
12751275 , boolQueryDisableCoord :: Maybe DisableCoord
1276− } deriving (Eq, Show, Typeable)
1276+ } deriving (Eq, Show, Generic, Typeable)
12771277
12781278mkBoolQuery :: [Query] -> [Query] -> [Query] -> BoolQuery
12791279mkBoolQuery must mustNot should =
@@ -1282,7 +1282,7 @@ mkBoolQuery must mustNot should =
12821282data BoostingQuery =
12831283 BoostingQuery { positiveQuery :: Query
12841284 , negativeQuery :: Query
1285− , negativeBoost :: Boost } deriving (Eq, Show, Typeable)
1285+ , negativeBoost :: Boost } deriving (Eq, Show, Generic, Typeable)
12861286
12871287data CommonTermsQuery =
12881288 CommonTermsQuery { commonField :: FieldName
@@ -1294,16 +1294,16 @@ data CommonTermsQuery =
12941294 , commonBoost :: Maybe Boost
12951295 , commonAnalyzer :: Maybe Analyzer
12961296 , commonDisableCoord :: Maybe DisableCoord
1297− } deriving (Eq, Show, Typeable)
1297+ } deriving (Eq, Show, Generic, Typeable)
12981298
12991299data CommonMinimumMatch =
13001300 CommonMinimumMatchHighLow MinimumMatchHighLow
13011301 | CommonMinimumMatch MinimumMatch
1302− deriving (Eq, Show, Typeable)
1302+ deriving (Eq, Show, Generic, Typeable)
13031303
13041304data MinimumMatchHighLow =
13051305 MinimumMatchHighLow { lowFreq :: MinimumMatch
1306− , highFreq :: MinimumMatch } deriving (Eq, Show, Typeable)
1306+ , highFreq :: MinimumMatch } deriving (Eq, Show, Generic, Typeable)
13071307
13081308data Filter = AndFilter [Filter] Cache
13091309 | OrFilter [Filter] Cache
@@ -1323,36 +1323,36 @@ data Filter = AndFilter [Filter] Cache
13231323 | RangeFilter FieldName RangeValue RangeExecution Cache
13241324 | RegexpFilter FieldName Regexp RegexpFlags CacheName Cache CacheKey
13251325 | TermFilter Term Cache
1326− deriving (Eq, Show, Typeable)
1326+ deriving (Eq, Show, Generic, Typeable)
13271327
13281328data ZeroTermsQuery = ZeroTermsNone
1329− | ZeroTermsAll deriving (Eq, Show, Typeable)
1329+ | ZeroTermsAll deriving (Eq, Show, Generic, Typeable)
13301330
13311331data RangeExecution = RangeExecutionIndex
1332− | RangeExecutionFielddata deriving (Eq, Show, Typeable)
1332+ | RangeExecutionFielddata deriving (Eq, Show, Generic, Typeable)
13331333
1334−newtype Regexp = Regexp Text deriving (Eq, Show, FromJSON)
1334+newtype Regexp = Regexp Text deriving (Eq, Show, Generic, FromJSON)
13351335
13361336data RegexpFlags = AllRegexpFlags
13371337 | NoRegexpFlags
1338− | SomeRegexpFlags (NonEmpty RegexpFlag) deriving (Eq, Show)
1338+ | SomeRegexpFlags (NonEmpty RegexpFlag) deriving (Eq, Show, Generic)
13391339
13401340data RegexpFlag = AnyString
13411341 | Automaton
13421342 | Complement
13431343 | Empty
13441344 | Intersection
1345− | Interval deriving (Eq, Show)
1345+ | Interval deriving (Eq, Show, Generic)
13461346
1347−newtype LessThan = LessThan Double deriving (Eq, Show)
1348−newtype LessThanEq = LessThanEq Double deriving (Eq, Show)
1349−newtype GreaterThan = GreaterThan Double deriving (Eq, Show)
1350−newtype GreaterThanEq = GreaterThanEq Double deriving (Eq, Show)
1347+newtype LessThan = LessThan Double deriving (Eq, Show, Generic)
1348+newtype LessThanEq = LessThanEq Double deriving (Eq, Show, Generic)
1349+newtype GreaterThan = GreaterThan Double deriving (Eq, Show, Generic)
1350+newtype GreaterThanEq = GreaterThanEq Double deriving (Eq, Show, Generic)
13511351
1352−newtype LessThanD = LessThanD UTCTime deriving (Eq, Show)
1353−newtype LessThanEqD = LessThanEqD UTCTime deriving (Eq, Show)
1354−newtype GreaterThanD = GreaterThanD UTCTime deriving (Eq, Show)
1355−newtype GreaterThanEqD = GreaterThanEqD UTCTime deriving (Eq, Show)
1352+newtype LessThanD = LessThanD UTCTime deriving (Eq, Show, Generic)
1353+newtype LessThanEqD = LessThanEqD UTCTime deriving (Eq, Show, Generic)
1354+newtype GreaterThanD = GreaterThanD UTCTime deriving (Eq, Show, Generic)
1355+newtype GreaterThanEqD = GreaterThanEqD UTCTime deriving (Eq, Show, Generic)
13561356
13571357data RangeValue = RangeDateLte LessThanEqD
13581358 | RangeDateLt LessThanD
@@ -1370,7 +1370,7 @@ data RangeValue = RangeDateLte LessThanEqD
13701370 | RangeDoubleGteLte GreaterThanEq LessThanEq
13711371 | RangeDoubleGteLt GreaterThanEq LessThan
13721372 | RangeDoubleGtLte GreaterThan LessThanEq
1373− deriving (Eq, Show)
1373+ deriving (Eq, Show, Generic)
13741374
13751375rangeValueToPair :: RangeValue -> [Pair]
13761376rangeValueToPair rv = case rv of
@@ -1392,33 +1392,33 @@ rangeValueToPair rv = case rv of
13921392 RangeDoubleGtLt (GreaterThan l) (LessThan g) -> ["gt" .= l, "lt" .= g]
13931393
13941394data Term = Term { termField :: Text
1395− , termValue :: Text } deriving (Eq, Show, Typeable)
1395+ , termValue :: Text } deriving (Eq, Show, Generic, Typeable)
13961396
13971397data BoolMatch = MustMatch Term Cache
13981398 | MustNotMatch Term Cache
1399− | ShouldMatch [Term] Cache deriving (Eq, Show, Typeable)
1399+ | ShouldMatch [Term] Cache deriving (Eq, Show, Generic, Typeable)
14001400
14011401-- "memory" or "indexed"
14021402data GeoFilterType = GeoFilterMemory
1403− | GeoFilterIndexed deriving (Eq, Show, Typeable)
1403+ | GeoFilterIndexed deriving (Eq, Show, Generic, Typeable)
14041404
14051405data LatLon = LatLon { lat :: Double
1406− , lon :: Double } deriving (Eq, Show, Typeable)
1406+ , lon :: Double } deriving (Eq, Show, Generic, Typeable)
14071407
14081408data GeoBoundingBox =
14091409 GeoBoundingBox { topLeft :: LatLon
1410− , bottomRight :: LatLon } deriving (Eq, Show, Typeable)
1410+ , bottomRight :: LatLon } deriving (Eq, Show, Generic, Typeable)
14111411
14121412data GeoBoundingBoxConstraint =
14131413 GeoBoundingBoxConstraint { geoBBField :: FieldName
14141414 , constraintBox :: GeoBoundingBox
14151415 , bbConstraintcache :: Cache
14161416 , geoType :: GeoFilterType
1417− } deriving (Eq, Show, Typeable)
1417+ } deriving (Eq, Show, Generic, Typeable)
14181418
14191419data GeoPoint =
14201420 GeoPoint { geoField :: FieldName
1421− , latLon :: LatLon} deriving (Eq, Show, Typeable)
1421+ , latLon :: LatLon} deriving (Eq, Show, Generic, Typeable)
14221422
14231423data DistanceUnit = Miles
14241424 | Yards
@@ -1428,22 +1428,22 @@ data DistanceUnit = Miles
14281428 | Meters
14291429 | Centimeters
14301430 | Millimeters
1431− | NauticalMiles deriving (Eq, Show, Typeable)
1431+ | NauticalMiles deriving (Eq, Show, Generic, Typeable)
14321432
14331433data DistanceType = Arc
14341434 | SloppyArc -- doesn't exist <1.0
1435− | Plane deriving (Eq, Show, Typeable)
1435+ | Plane deriving (Eq, Show, Generic, Typeable)
14361436
14371437data OptimizeBbox = OptimizeGeoFilterType GeoFilterType
1438− | NoOptimizeBbox deriving (Eq, Show, Typeable)
1438+ | NoOptimizeBbox deriving (Eq, Show, Generic, Typeable)
14391439
14401440data Distance =
14411441 Distance { coefficient :: Double
1442− , unit :: DistanceUnit } deriving (Eq, Show, Typeable)
1442+ , unit :: DistanceUnit } deriving (Eq, Show, Generic, Typeable)
14431443
14441444data DistanceRange =
14451445 DistanceRange { distanceFrom :: Distance
1446− , distanceTo :: Distance } deriving (Eq, Show)
1446+ , distanceTo :: Distance } deriving (Eq, Show, Generic)
14471447
14481448data SearchResult a =
14491449 SearchResult { took :: Int
@@ -1451,16 +1451,16 @@ data SearchResult a =
14511451 , shards :: ShardResult
14521452 , searchHits :: SearchHits a
14531453 , aggregations :: Maybe AggregationResults
1454− , scrollId :: Maybe ScrollId } deriving (Eq, Show)
1454+ , scrollId :: Maybe ScrollId } deriving (Eq, Show, Generic)
14551455
1456−newtype ScrollId = ScrollId Text deriving (Eq, Show, Ord, ToJSON, FromJSON)
1456+newtype ScrollId = ScrollId Text deriving (Eq, Show, Generic, Ord, ToJSON, FromJSON)
14571457
14581458type Score = Maybe Double
14591459
14601460data SearchHits a =
14611461 SearchHits { hitsTotal :: Int
14621462 , maxScore :: Score
1463− , hits :: [Hit a] } deriving (Eq, Show)
1463+ , hits :: [Hit a] } deriving (Eq, Show, Generic)
14641464
14651465
14661466instance Monoid (SearchHits a) where
@@ -1475,7 +1475,7 @@ data Hit a =
14751475 , hitDocId :: DocId
14761476 , hitScore :: Score
14771477 , hitSource :: Maybe a
1478− , hitHighlight :: Maybe HitHighlight } deriving (Eq, Show)
1478+ , hitHighlight :: Maybe HitHighlight } deriving (Eq, Show, Generic)
14791479
14801480data ShardResult =
14811481 ShardResult { shardTotal :: Int
@@ -1504,19 +1504,19 @@ mkAggregations :: Text -> Aggregation -> Aggregations
15041504mkAggregations name aggregation = M.insert name aggregation emptyAggregations
15051505
15061506data TermOrder = TermOrder{ termSortField :: Text
1507− , termSortOrder :: SortOrder } deriving (Eq, Show)
1507+ , termSortOrder :: SortOrder } deriving (Eq, Show, Generic)
15081508
15091509data TermInclusion = TermInclusion Text
1510− | TermPattern Text Text deriving (Eq, Show)
1510+ | TermPattern Text Text deriving (Eq, Show, Generic)
15111511
15121512data CollectionMode = BreadthFirst
1513− | DepthFirst deriving (Eq, Show)
1513+ | DepthFirst deriving (Eq, Show, Generic)
15141514
15151515data ExecutionHint = Ordinals
15161516 | GlobalOrdinals
15171517 | GlobalOrdinalsHash
15181518 | GlobalOrdinalsLowCardinality
1519− | Map deriving (Eq, Show)
1519+ | Map deriving (Eq, Show, Generic)
15201520
15211521data TimeInterval = Weeks
15221522 | Days
@@ -1532,13 +1532,13 @@ data Interval = Year
15321532 | Hour
15331533 | Minute
15341534 | Second
1535− | FractionalInterval Float TimeInterval deriving (Eq, Show)
1535+ | FractionalInterval Float TimeInterval deriving (Eq, Show, Generic)
15361536
15371537data Aggregation = TermsAgg TermsAggregation
15381538 | DateHistogramAgg DateHistogramAggregation
15391539 | ValueCountAgg ValueCountAggregation
15401540 | FilterAgg FilterAggregation
1541− | DateRangeAgg DateRangeAggregation deriving (Eq, Show)
1541+ | DateRangeAgg DateRangeAggregation deriving (Eq, Show, Generic)
15421542
15431543
15441544data TermsAggregation = TermsAggregation { term :: Either Text Text
@@ -1551,7 +1551,7 @@ data TermsAggregation = TermsAggregation { term :: Either Text Text
15511551 , termCollectMode :: Maybe CollectionMode
15521552 , termExecutionHint :: Maybe ExecutionHint
15531553 , termAggs :: Maybe Aggregations
1554− } deriving (Eq, Show)
1554+ } deriving (Eq, Show, Generic)
15551555
15561556data DateHistogramAggregation = DateHistogramAggregation { dateField :: FieldName
15571557 , dateInterval :: Interval
@@ -1562,29 +1562,29 @@ data DateHistogramAggregation = DateHistogramAggregation { dateField :: Fie
15621562 , datePreOffset :: Maybe Text
15631563 , datePostOffset :: Maybe Text
15641564 , dateAggs :: Maybe Aggregations
1565− } deriving (Eq, Show)
1565+ } deriving (Eq, Show, Generic)
15661566
15671567
15681568data DateRangeAggregation = DateRangeAggregation { draField :: FieldName
15691569 , draFormat :: Maybe Text
15701570 , draRanges :: NonEmpty DateRangeAggRange
1571− } deriving (Eq, Show)
1571+ } deriving (Eq, Show, Generic)
15721572
15731573data DateRangeAggRange = DateRangeFrom DateMathExpr
15741574 | DateRangeTo DateMathExpr
1575− | DateRangeFromAndTo DateMathExpr DateMathExpr deriving (Eq, Show)
1575+ | DateRangeFromAndTo DateMathExpr DateMathExpr deriving (Eq, Show, Generic)
15761576
15771577-- | See <https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math> for more information.
1578−data DateMathExpr = DateMathExpr DateMathAnchor [DateMathModifier] deriving (Eq, Show)
1578+data DateMathExpr = DateMathExpr DateMathAnchor [DateMathModifier] deriving (Eq, Show, Generic)
15791579
15801580
15811581-- | Starting point for a date range. This along with the 'DateMathModifiers' gets you the date ES will start from.
15821582data DateMathAnchor = DMNow
1583− | DMDate Day deriving (Eq, Show)
1583+ | DMDate Day deriving (Eq, Show, Generic)
15841584
15851585data DateMathModifier = AddTime Int DateMathUnit
15861586 | SubtractTime Int DateMathUnit
1587− | RoundDownTo DateMathUnit deriving (Eq, Show)
1587+ | RoundDownTo DateMathUnit deriving (Eq, Show, Generic)
15881588
15891589data DateMathUnit = DMYear
15901590 | DMMonth
@@ -1592,15 +1592,15 @@ data DateMathUnit = DMYear
15921592 | DMDay
15931593 | DMHour
15941594 | DMMinute
1595− | DMSecond deriving (Eq, Show)
1595+ | DMSecond deriving (Eq, Show, Generic)
15961596
15971597-- | See <https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-valuecount-aggregation.html> for more information.
15981598data ValueCountAggregation = FieldValueCount FieldName
1599− | ScriptValueCount Script deriving (Eq, Show)
1599+ | ScriptValueCount Script deriving (Eq, Show, Generic)
16001600
16011601-- | Single-bucket filter aggregations. See <https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html#search-aggregations-bucket-filter-aggregation> for more information.
16021602data FilterAggregation = FilterAggregation { faFilter :: Filter
1603− , faAggs :: Maybe Aggregations} deriving (Eq, Show)
1603+ , faAggs :: Maybe Aggregations} deriving (Eq, Show, Generic)
16041604
16051605mkTermsAggregation :: Text -> TermsAggregation
16061606mkTermsAggregation t = TermsAggregation (Left t) Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
@@ -1756,7 +1756,7 @@ data DateRangeResult = DateRangeResult { dateRangeKey :: Text
17561756 , dateRangeTo :: Maybe UTCTime
17571757 , dateRangeToAsString :: Maybe Text
17581758 , dateRangeDocCount :: Int
1759− , dateRangeAggs :: Maybe AggregationResults } deriving (Show, Eq)
1759+ , dateRangeAggs :: Maybe AggregationResults } deriving (Show, Eq, Generic)
17601760
17611761toTerms :: Text -> AggregationResults -> Maybe (Bucket TermsResult)
17621762toTerms t a = M.lookup t a >>= deserialize
@@ -2861,7 +2861,7 @@ instance FromJSON UpdatableIndexSetting where
28612861 <|> blocksWrite `taggedAt` ["blocks", "write"]
28622862 <|> blocksMetaData `taggedAt` ["blocks", "metadata"]
28632863 where taggedAt f ks = taggedAt' f (Object o) ks
2864− taggedAt' f v [] = f =<< parseJSON v
2864+ taggedAt' f v [] = f =<< (parseJSON v <|> (parseJSON =<< unStringlyTypeJSON v))
28652865 taggedAt' f v (k:ks) = withObject "Object" (\o -> do v' <- o .: k
28662866 taggedAt' f v' ks) v
28672867 numberOfReplicas = pure . NumberOfReplicas
@@ -2896,10 +2896,37 @@ instance FromJSON UpdatableIndexSetting where
28962896instance FromJSON IndexSettingsSummary where
28972897 parseJSON = withObject "IndexSettingsSummary" parse
28982898 where parse o = case HM.toList o of
2899− [(ixn, v)] -> IndexSettingsSummary (IndexName ixn)
2900− <$> parseJSON v
2901− <*> parseJSON v
2899+ [(ixn, v@(Object o'))] -> IndexSettingsSummary (IndexName ixn)
2900+ <$> parseJSON v
2901+ <*> (fmap (filter (not . redundant)) . parseSettings =<< o' .: "settings")
29022902 _ -> fail "Expected single-key object with index name"
2903+ redundant (NumberOfReplicas _) = True
2904+ redundant _ = False
2905+
2906+-- | For some reason in the settings API, all leaf values get returned
2907+-- as strings. This function attepmts to recover from this for all
2908+-- non-recursive JSON types. If nothing can be done or the same value
2909+-- would be return, it returns 'mzero'
2910+unStringlyTypeJSON :: MonadPlus m => Value -> m Value
2911+unStringlyTypeJSON (String "true") = return (Bool True)
2912+unStringlyTypeJSON (String "false") = return (Bool False)
2913+unStringlyTypeJSON (String "null") = return Null
2914+unStringlyTypeJSON (String t) = case readMay (T.unpack t) of
2915+ Just n -> return (Number n)
2916+ Nothing -> mzero
2917+unStringlyTypeJSON _ = mzero
2918+
2919+
2920+parseSettings :: Object -> Parser [UpdatableIndexSetting]
2921+parseSettings o = do
2922+ o' <- o .: "index"
2923+ -- slice the index object into singleton hashmaps and try to parse each
2924+ parses <- forM (HM.toList o') $ \(k, v) -> do
2925+ -- blocks are now nested into the "index" key, which is not how they're serialized
2926+ let atRoot = Object (HM.singleton k v)
2927+ let atIndex = Object (HM.singleton "index" atRoot)
2928+ optional (parseJSON atRoot <|> parseJSON atIndex)
2929+ return (catMaybes parses)
29032930
29042931oPath :: ToJSON a => NonEmpty Text -> a -> Value
29052932oPath (k :| []) v = object [k .= v]
@@ -2989,7 +3016,7 @@ instance ToJSON NominalDiffTimeJSON where
29893016instance FromJSON NominalDiffTimeJSON where
29903017 parseJSON = withText "NominalDiffTime" parse
29913018 where parse t = case T.takeEnd 1 t of
2992− "s" -> NominalDiffTimeJSON . fromInteger <$> parseReadText t
3019+ "s" -> NominalDiffTimeJSON . fromInteger <$> parseReadText (T.dropEnd 1 t)
29933020 _ -> fail "Invalid or missing NominalDiffTime unit (expected s)"
29943021
29953022instance ToJSON IndexTemplate where
@@ -3477,6 +3504,19 @@ instance FromJSON DocVersion where
34773504 i <- parseJSON v
34783505 maybe (fail "DocVersion out of range") return $ mkDocVersion i
34793506
3507+-- This insanity is because ES *sometimes* returns Replica/Shard counts as strings
3508+instance FromJSON ReplicaCount where
3509+ parseJSON v = parseAsInt v
3510+ <|> parseAsString v
3511+ where parseAsInt = fmap ReplicaCount . parseJSON
3512+ parseAsString = withText "ReplicaCount" (fmap ReplicaCount . parseReadText)
3513+
3514+instance FromJSON ShardCount where
3515+ parseJSON v = parseAsInt v
3516+ <|> parseAsString v
3517+ where parseAsInt = fmap ShardCount . parseJSON
3518+ parseAsString = withText "ShardCount" (fmap ShardCount . parseReadText)
3519+
34803520instance Bounded DocVersion where
34813521 minBound = DocVersion 1
34823522 maxBound = DocVersion 9200000000000000000 -- 9.2e+18