@@ -368,7 +368,7 @@ data Status = Status { ok :: Maybe Bool
368 , status :: Int
368 , status :: Int
369 , name :: Text
369 , name :: Text
370 , version :: Version
370 , version :: Version
371− , tagline :: Text } deriving (Eq, Show)
371+ , tagline :: Text } deriving (Eq, Show, Generic)
373{-| 'IndexSettings' is used to configure the shards and replicas when you create
373{-| 'IndexSettings' is used to configure the shards and replicas when you create
374 an Elasticsearch Index.
374 an Elasticsearch Index.
@@ -378,7 +378,7 @@ data Status = Status { ok :: Maybe Bool
379data IndexSettings =
379data IndexSettings =
380 IndexSettings { indexShards :: ShardCount
380 IndexSettings { indexShards :: ShardCount
381− , indexReplicas :: ReplicaCount } deriving (Eq, Show)
381+ , indexReplicas :: ReplicaCount } deriving (Eq, Show, Generic)
383{-| 'defaultIndexSettings' is an 'IndexSettings' with 3 shards and 2 replicas. -}
383{-| 'defaultIndexSettings' is an 'IndexSettings' with 3 shards and 2 replicas. -}
384defaultIndexSettings :: IndexSettings
384defaultIndexSettings :: IndexSettings
@@ -436,7 +436,7 @@ data UpdatableIndexSetting = NumberOfReplicas ReplicaCount
436 | IndexCompoundFormat CompoundFormat
436 | IndexCompoundFormat CompoundFormat
437 | IndexCompoundOnFlush Bool
437 | IndexCompoundOnFlush Bool
438 | WarmerEnabled Bool
438 | WarmerEnabled Bool
439− deriving (Eq, Show)
439+ deriving (Eq, Show, Generic)
441data AllocationPolicy = AllocAll
441data AllocationPolicy = AllocAll
442 -- ^ Allows shard allocation for all shards.
442 -- ^ Allows shard allocation for all shards.
@@ -446,42 +446,42 @@ data AllocationPolicy = AllocAll
446 -- ^ Allows shard allocation only for primary shards for new indices.
446 -- ^ Allows shard allocation only for primary shards for new indices.
447 | AllocNone
447 | AllocNone
448 -- ^ No shard allocation is allowed
448 -- ^ No shard allocation is allowed
449− deriving (Eq, Show)
449+ deriving (Eq, Show, Generic)
451data ReplicaBounds = ReplicasBounded Int Int
451data ReplicaBounds = ReplicasBounded Int Int
452 | ReplicasLowerBounded Int
452 | ReplicasLowerBounded Int
453 | ReplicasUnbounded
453 | ReplicasUnbounded
454− deriving (Eq, Show)
454+ deriving (Eq, Show, Generic)
456−newtype Bytes = Bytes Int deriving (Eq, Show, Ord, ToJSON, FromJSON)
456+newtype Bytes = Bytes Int deriving (Eq, Show, Generic, Ord, ToJSON, FromJSON)
458data FSType = FSSimple
458data FSType = FSSimple
459− | FSBuffered deriving (Eq, Show, Ord)
459+ | FSBuffered deriving (Eq, Show, Generic, Ord)
461data InitialShardCount = QuorumShards
461data InitialShardCount = QuorumShards
462 | QuorumMinus1Shards
462 | QuorumMinus1Shards
463 | FullShards
463 | FullShards
464 | FullMinus1Shards
464 | FullMinus1Shards
465 | ExplicitShards Int
465 | ExplicitShards Int
466− deriving (Eq, Show)
466+ deriving (Eq, Show, Generic)
468data NodeAttrFilter = NodeAttrFilter { nodeAttrFilterName :: NodeAttrName
468data NodeAttrFilter = NodeAttrFilter { nodeAttrFilterName :: NodeAttrName
469 , nodeAttrFilterValues :: NonEmpty Text}
469 , nodeAttrFilterValues :: NonEmpty Text}
470− deriving (Eq, Show)
470+ deriving (Eq, Show, Generic, Ord)
472−newtype NodeAttrName = NodeAttrName Text deriving (Eq, Show)
472+newtype NodeAttrName = NodeAttrName Text deriving (Eq, Show, Ord, Generic)
474data CompoundFormat = CompoundFileFormat Bool
474data CompoundFormat = CompoundFileFormat Bool
475 | MergeSegmentVsTotalIndex Double
475 | MergeSegmentVsTotalIndex Double
476 -- ^ percentage between 0 and 1 where 0 is false, 1 is true
476 -- ^ percentage between 0 and 1 where 0 is false, 1 is true
477− deriving (Eq, Show)
477+ deriving (Eq, Show, Generic)
479newtype NominalDiffTimeJSON = NominalDiffTimeJSON { ndtJSON :: NominalDiffTime }
479newtype NominalDiffTimeJSON = NominalDiffTimeJSON { ndtJSON :: NominalDiffTime }
481data IndexSettingsSummary = IndexSettingsSummary { sSummaryIndexName :: IndexName
481data IndexSettingsSummary = IndexSettingsSummary { sSummaryIndexName :: IndexName
482 , sSummaryFixedSettings :: IndexSettings
482 , sSummaryFixedSettings :: IndexSettings
483 , sSummaryUpdateable :: [UpdatableIndexSetting]}
483 , sSummaryUpdateable :: [UpdatableIndexSetting]}
484− deriving (Eq, Show)
484+ deriving (Eq, Show, Generic)
486{-| 'Reply' and 'Method' are type synonyms from 'Network.HTTP.Types.Method.Method' -}
486{-| 'Reply' and 'Method' are type synonyms from 'Network.HTTP.Types.Method.Method' -}
487type Reply = Network.HTTP.Client.Response L.ByteString
487type Reply = Network.HTTP.Client.Response L.ByteString
@@ -491,7 +491,7 @@ type Method = NHTM.Method
492 <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-open-close.html>
492 <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-open-close.html>
494−data OpenCloseIndex = OpenIndex | CloseIndex deriving (Eq, Show)
494+data OpenCloseIndex = OpenIndex | CloseIndex deriving (Eq, Show, Generic)
496data FieldType = GeoPointType
496data FieldType = GeoPointType
497 | GeoShapeType
497 | GeoShapeType
@@ -499,10 +499,10 @@ data FieldType = GeoPointType
499 | IntegerType
499 | IntegerType
500 | LongType
500 | LongType
501 | ShortType
501 | ShortType
502− | ByteType deriving (Eq, Show)
502+ | ByteType deriving (Eq, Show, Generic)
504data FieldDefinition =
504data FieldDefinition =
505− FieldDefinition { fieldType :: FieldType } deriving (Eq, Show)
505+ FieldDefinition { fieldType :: FieldType } deriving (Eq, Show, Generic)
507{-| An 'IndexTemplate' defines a template that will automatically be
507{-| An 'IndexTemplate' defines a template that will automatically be
508 applied to new indices created. The templates include both
508 applied to new indices created. The templates include both
@@ -520,7 +520,7 @@ data IndexTemplate =
521data MappingField =
521data MappingField =
522 MappingField { mappingFieldName :: FieldName
522 MappingField { mappingFieldName :: FieldName
523− , fieldDefinition :: FieldDefinition } deriving (Eq, Show)
523+ , fieldDefinition :: FieldDefinition } deriving (Eq, Show, Generic)
525{-| Support for type reification of 'Mapping's is currently incomplete, for
525{-| Support for type reification of 'Mapping's is currently incomplete, for
526 now the mapping API verbiage expects a 'ToJSON'able blob.
526 now the mapping API verbiage expects a 'ToJSON'able blob.
@@ -530,7 +530,7 @@ data MappingField =
530 and keeping different kinds of documents separated if possible.
530 and keeping different kinds of documents separated if possible.
532data Mapping = Mapping { typeName :: TypeName
532data Mapping = Mapping { typeName :: TypeName
533− , mappingFields :: [MappingField] } deriving (Eq, Show)
533+ , mappingFields :: [MappingField] } deriving (Eq, Show, Generic)
535{-| 'BulkOperation' is a sum type for expressing the four kinds of bulk
535{-| 'BulkOperation' is a sum type for expressing the four kinds of bulk
536 operation index, create, delete, and update. 'BulkIndex' behaves like an
536 operation index, create, delete, and update. 'BulkIndex' behaves like an
@@ -542,7 +542,7 @@ data BulkOperation =
542 BulkIndex IndexName MappingName DocId Value
542 BulkIndex IndexName MappingName DocId Value
543 | BulkCreate IndexName MappingName DocId Value
543 | BulkCreate IndexName MappingName DocId Value
544 | BulkDelete IndexName MappingName DocId
544 | BulkDelete IndexName MappingName DocId
545− | BulkUpdate IndexName MappingName DocId Value deriving (Eq, Show)
545+ | BulkUpdate IndexName MappingName DocId Value deriving (Eq, Show, Generic)
547{-| 'EsResult' describes the standard wrapper JSON document that you see in
547{-| 'EsResult' describes the standard wrapper JSON document that you see in
548 successful Elasticsearch lookups or lookups that couldn't find the document.
548 successful Elasticsearch lookups or lookups that couldn't find the document.
@@ -550,55 +550,55 @@ data BulkOperation =
550data EsResult a = EsResult { _index :: Text
550data EsResult a = EsResult { _index :: Text
551 , _type :: Text
551 , _type :: Text
552 , _id :: Text
552 , _id :: Text
553− , foundResult :: Maybe (EsResultFound a)} deriving (Eq, Show)
553+ , foundResult :: Maybe (EsResultFound a)} deriving (Eq, Show, Generic)
555{-| 'EsResultFound' contains the document and its metadata inside of an
555{-| 'EsResultFound' contains the document and its metadata inside of an
556 'EsResult' when the document was successfully found.
556 'EsResult' when the document was successfully found.
558data EsResultFound a = EsResultFound { _version :: DocVersion
558data EsResultFound a = EsResultFound { _version :: DocVersion
559− , _source :: a } deriving (Eq, Show)
559+ , _source :: a } deriving (Eq, Show, Generic)
561{-| 'EsError' is the generic type that will be returned when there was a
561{-| 'EsError' is the generic type that will be returned when there was a
562 problem. If you can't parse the expected response, its a good idea to
562 problem. If you can't parse the expected response, its a good idea to
563 try parsing this.
563 try parsing this.
565data EsError = EsError { errorStatus :: Int
565data EsError = EsError { errorStatus :: Int
566− , errorMessage :: Text } deriving (Eq, Show)
566+ , errorMessage :: Text } deriving (Eq, Show, Generic)
568data IndexAlias = IndexAlias { srcIndex :: IndexName
568data IndexAlias = IndexAlias { srcIndex :: IndexName
569− , indexAlias :: IndexAliasName } deriving (Eq, Show)
569+ , indexAlias :: IndexAliasName } deriving (Eq, Show, Generic)
571−newtype IndexAliasName = IndexAliasName { indexAliasName :: IndexName } deriving (Eq, Show, ToJSON)
571+newtype IndexAliasName = IndexAliasName { indexAliasName :: IndexName } deriving (Eq, Show, Generic, ToJSON)
573data IndexAliasAction = AddAlias IndexAlias IndexAliasCreate
573data IndexAliasAction = AddAlias IndexAlias IndexAliasCreate
574− | RemoveAlias IndexAlias deriving (Show, Eq, Typeable)
574+ | RemoveAlias IndexAlias deriving (Show, Eq, Generic, Typeable)
576data IndexAliasCreate = IndexAliasCreate { aliasCreateRouting :: Maybe AliasRouting
576data IndexAliasCreate = IndexAliasCreate { aliasCreateRouting :: Maybe AliasRouting
577 , aliasCreateFilter :: Maybe Filter}
577 , aliasCreateFilter :: Maybe Filter}
578− deriving (Show, Eq, Typeable)
578+ deriving (Show, Eq, Generic, Typeable)
580data AliasRouting = AllAliasRouting RoutingValue
580data AliasRouting = AllAliasRouting RoutingValue
581 | GranularAliasRouting (Maybe SearchAliasRouting) (Maybe IndexAliasRouting)
581 | GranularAliasRouting (Maybe SearchAliasRouting) (Maybe IndexAliasRouting)
582− deriving (Show, Eq, Typeable)
582+ deriving (Show, Eq, Generic, Typeable)
584−newtype SearchAliasRouting = SearchAliasRouting (NonEmpty RoutingValue) deriving (Show, Eq, Typeable)
584+newtype SearchAliasRouting = SearchAliasRouting (NonEmpty RoutingValue) deriving (Show, Eq, Generic, Typeable)
586−newtype IndexAliasRouting = IndexAliasRouting RoutingValue deriving (Show, Eq, ToJSON, FromJSON, Typeable)
586+newtype IndexAliasRouting = IndexAliasRouting RoutingValue deriving (Show, Eq, Generic, ToJSON, FromJSON, Typeable)
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)
590−newtype IndexAliasesSummary = IndexAliasesSummary { indexAliasesSummary :: [IndexAliasSummary] } deriving (Show, Eq, Typeable)
590+newtype IndexAliasesSummary = IndexAliasesSummary { indexAliasesSummary :: [IndexAliasSummary] } deriving (Show, Eq, Generic, Typeable)
592{-| 'IndexAliasSummary' is a summary of an index alias configured for a server. -}
592{-| 'IndexAliasSummary' is a summary of an index alias configured for a server. -}
593data IndexAliasSummary = IndexAliasSummary { indexAliasSummaryAlias :: IndexAlias
593data IndexAliasSummary = IndexAliasSummary { indexAliasSummaryAlias :: IndexAlias
594− , indexAliasSummaryCreate :: IndexAliasCreate} deriving (Show, Eq)
594+ , indexAliasSummaryCreate :: IndexAliasCreate} deriving (Show, Eq, Generic)
596{-| 'DocVersion' is an integer version number for a document between 1
596{-| 'DocVersion' is an integer version number for a document between 1
597and 9.2e+18 used for <<https://www.elastic.co/guide/en/elasticsearch/guide/current/optimistic-concurrency-control.html optimistic concurrency control>>.
597and 9.2e+18 used for <<https://www.elastic.co/guide/en/elasticsearch/guide/current/optimistic-concurrency-control.html optimistic concurrency control>>.
599newtype DocVersion = DocVersion {
599newtype DocVersion = DocVersion {
600 docVersionNumber :: Int
600 docVersionNumber :: Int
601− } deriving (Eq, Show, Ord, ToJSON)
601+ } deriving (Eq, Show, Generic, Ord, ToJSON)
603-- | Smart constructor for in-range doc version
603-- | Smart constructor for in-range doc version
604mkDocVersion :: Int -> Maybe DocVersion
604mkDocVersion :: Int -> Maybe DocVersion
@@ -612,7 +612,7 @@ mkDocVersion i
612own version numbers instead of ones from ES.
612own version numbers instead of ones from ES.
614newtype ExternalDocVersion = ExternalDocVersion DocVersion
614newtype ExternalDocVersion = ExternalDocVersion DocVersion
615− deriving (Eq, Show, Ord, Bounded, Enum, ToJSON)
615+ deriving (Eq, Show, Generic, Ord, Bounded, Enum, ToJSON)
617{-| 'VersionControl' is specified when indexing documents as a
617{-| 'VersionControl' is specified when indexing documents as a
618optimistic concurrency control.
618optimistic concurrency control.
@@ -646,12 +646,12 @@ data VersionControl = NoVersionControl
646 -- given version will be the new version. This is
646 -- given version will be the new version. This is
647 -- typically used for correcting errors. Use with
647 -- typically used for correcting errors. Use with
648 -- care, as this could result in data loss.
648 -- care, as this could result in data loss.
649− deriving (Show, Eq, Ord)
649+ deriving (Show, Eq, Generic, Ord)
651{-| 'DocumentParent' is used to specify a parent document.
651{-| 'DocumentParent' is used to specify a parent document.
653newtype DocumentParent = DocumentParent DocId
653newtype DocumentParent = DocumentParent DocId
654− deriving (Eq, Show)
654+ deriving (Eq, Show, Generic)
656{-| 'IndexDocumentSettings' are special settings supplied when indexing
656{-| 'IndexDocumentSettings' are special settings supplied when indexing
657a document. For the best backwards compatiblity when new fields are
657a document. For the best backwards compatiblity when new fields are
@@ -660,7 +660,7 @@ added, you should probably prefer to start with 'defaultIndexDocumentSettings'
660data IndexDocumentSettings =
660data IndexDocumentSettings =
661 IndexDocumentSettings { idsVersionControl :: VersionControl
661 IndexDocumentSettings { idsVersionControl :: VersionControl
662 , idsParent :: Maybe DocumentParent
662 , idsParent :: Maybe DocumentParent
663− } deriving (Eq, Show)
663+ } deriving (Eq, Show, Generic)
665{-| Reasonable default settings. Chooses no version control and no parent.
665{-| Reasonable default settings. Chooses no version control and no parent.
@@ -680,7 +680,7 @@ type Sort = [SortSpec]
680<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#search-request-sort>
680<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#search-request-sort>
682data SortSpec = DefaultSortSpec DefaultSort
682data SortSpec = DefaultSortSpec DefaultSort
683− | GeoDistanceSortSpec SortOrder GeoPoint DistanceUnit deriving (Eq, Show)
683+ | GeoDistanceSortSpec SortOrder GeoPoint DistanceUnit deriving (Eq, Show, Generic)
685{-| 'DefaultSort' is usually the kind of 'SortSpec' you'll want. There's a
685{-| 'DefaultSort' is usually the kind of 'SortSpec' you'll want. There's a
686 'mkSort' convenience function for when you want to specify only the most
686 'mkSort' convenience function for when you want to specify only the most
@@ -695,7 +695,7 @@ data DefaultSort =
695 , ignoreUnmapped :: Bool
695 , ignoreUnmapped :: Bool
696 , sortMode :: Maybe SortMode
696 , sortMode :: Maybe SortMode
697 , missingSort :: Maybe Missing
697 , missingSort :: Maybe Missing
698− , nestedFilter :: Maybe Filter } deriving (Eq, Show)
698+ , nestedFilter :: Maybe Filter } deriving (Eq, Show, Generic)
700{-| 'SortOrder' is 'Ascending' or 'Descending', as you might expect. These get
700{-| 'SortOrder' is 'Ascending' or 'Descending', as you might expect. These get
701 encoded into "asc" or "desc" when turned into JSON.
701 encoded into "asc" or "desc" when turned into JSON.
@@ -703,7 +703,7 @@ data DefaultSort =
703<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#search-request-sort>
703<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#search-request-sort>
705data SortOrder = Ascending
705data SortOrder = Ascending
706− | Descending deriving (Eq, Show)
706+ | Descending deriving (Eq, Show, Generic)
708{-| 'Missing' prescribes how to handle missing fields. A missing field can be
708{-| 'Missing' prescribes how to handle missing fields. A missing field can be
709 sorted last, first, or using a custom value as a substitute.
709 sorted last, first, or using a custom value as a substitute.
@@ -712,7 +712,7 @@ data SortOrder = Ascending
713data Missing = LastMissing
713data Missing = LastMissing
714 | FirstMissing
714 | FirstMissing
715− | CustomMissing Text deriving (Eq, Show)
715+ | CustomMissing Text deriving (Eq, Show, Generic)
717{-| 'SortMode' prescribes how to handle sorting array/multi-valued fields.
717{-| 'SortMode' prescribes how to handle sorting array/multi-valued fields.
@@ -721,7 +721,7 @@ http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-req
721data SortMode = SortMin
721data SortMode = SortMin
722 | SortMax
722 | SortMax
723 | SortSum
723 | SortSum
724− | SortAvg deriving (Eq, Show)
724+ | SortAvg deriving (Eq, Show, Generic)
726{-| 'mkSort' defaults everything but the 'FieldName' and the 'SortOrder' so
726{-| 'mkSort' defaults everything but the 'FieldName' and the 'SortOrder' so
727 that you can concisely describe the usual kind of 'SortSpec's you want.
727 that you can concisely describe the usual kind of 'SortSpec's you want.
@@ -743,19 +743,19 @@ type PrefixValue = Text
743{-| 'BooleanOperator' is the usual And/Or operators with an ES compatible
743{-| 'BooleanOperator' is the usual And/Or operators with an ES compatible
744 JSON encoding baked in. Used all over the place.
744 JSON encoding baked in. Used all over the place.
746−data BooleanOperator = And | Or deriving (Eq, Show, Typeable)
746+data BooleanOperator = And | Or deriving (Eq, Show, Generic, Typeable)
748{-| 'ShardCount' is part of 'IndexSettings'
748{-| 'ShardCount' is part of 'IndexSettings'
750−newtype ShardCount = ShardCount Int deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
750+newtype ShardCount = ShardCount Int deriving (Eq, Show, Generic, ToJSON, Typeable)
752{-| 'ReplicaCount' is part of 'IndexSettings'
752{-| 'ReplicaCount' is part of 'IndexSettings'
754−newtype ReplicaCount = ReplicaCount Int deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
754+newtype ReplicaCount = ReplicaCount Int deriving (Eq, Show, Generic, ToJSON, Typeable)
756{-| 'Server' is used with the client functions to point at the ES instance
756{-| 'Server' is used with the client functions to point at the ES instance
758−newtype Server = Server Text deriving (Eq, Show)
758+newtype Server = Server Text deriving (Eq, Show, Generic)
760{-| 'IndexName' is used to describe which index to query/create/delete
760{-| 'IndexName' is used to describe which index to query/create/delete
@@ -787,27 +787,27 @@ newtype QueryString = QueryString Text deriving (Eq, Generic, Show, ToJSON, From
787{-| 'FieldName' is used all over the place wherever a specific field within
787{-| 'FieldName' is used all over the place wherever a specific field within
788 a document needs to be specified, usually in 'Query's or 'Filter's.
788 a document needs to be specified, usually in 'Query's or 'Filter's.
790−newtype FieldName = FieldName Text deriving (Eq, Show, ToJSON, FromJSON, Typeable)
790+newtype FieldName = FieldName Text deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
793{-| 'Script' is often used in place of 'FieldName' to specify more
793{-| 'Script' is often used in place of 'FieldName' to specify more
794complex ways of extracting a value from a document.
794complex ways of extracting a value from a document.
796−newtype Script = Script { scriptText :: Text } deriving (Eq, Show)
796+newtype Script = Script { scriptText :: Text } deriving (Eq, Show, Generic)
798{-| 'CacheName' is used in 'RegexpFilter' for describing the
798{-| 'CacheName' is used in 'RegexpFilter' for describing the
799 'CacheKey' keyed caching behavior.
799 'CacheKey' keyed caching behavior.
801−newtype CacheName = CacheName Text deriving (Eq, Show, ToJSON, FromJSON, Typeable)
801+newtype CacheName = CacheName Text deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
803{-| 'CacheKey' is used in 'RegexpFilter' to key regex caching.
803{-| 'CacheKey' is used in 'RegexpFilter' to key regex caching.
805newtype CacheKey =
805newtype CacheKey =
806− CacheKey Text deriving (Eq, Show, ToJSON, FromJSON, Typeable)
806+ CacheKey Text deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
807newtype Existence =
807newtype Existence =
808− Existence Bool deriving (Eq, Show, ToJSON, FromJSON, Typeable)
808+ Existence Bool deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
809newtype NullValue =
809newtype NullValue =
810− NullValue Bool deriving (Eq, Show, ToJSON, FromJSON, Typeable)
810+ NullValue Bool deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
811newtype CutoffFrequency =
811newtype CutoffFrequency =
812 CutoffFrequency Double deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
812 CutoffFrequency Double deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
813newtype Analyzer =
813newtype Analyzer =
@@ -900,8 +900,8 @@ unpackId :: DocId -> Text
900unpackId (DocId docId) = docId
900unpackId (DocId docId) = docId
902type TrackSortScores = Bool
902type TrackSortScores = Bool
903−newtype From = From Int deriving (Eq, Show, ToJSON)
903+newtype From = From Int deriving (Eq, Show, Generic, ToJSON)
904−newtype Size = Size Int deriving (Eq, Show, ToJSON)
904+newtype Size = Size Int deriving (Eq, Show, Generic, ToJSON)
906data Search = Search { queryBody :: Maybe Query
906data Search = Search { queryBody :: Maybe Query
907 , filterBody :: Maybe Filter
907 , filterBody :: Maybe Filter
@@ -914,7 +914,7 @@ data Search = Search { queryBody :: Maybe Query
914 , size :: Size
914 , size :: Size
915 , searchType :: SearchType
915 , searchType :: SearchType
916 , fields :: Maybe [FieldName]
916 , fields :: Maybe [FieldName]
917− , source :: Maybe Source } deriving (Eq, Show)
917+ , source :: Maybe Source } deriving (Eq, Show, Generic)
919data SearchType = SearchTypeQueryThenFetch
919data SearchType = SearchTypeQueryThenFetch
920 | SearchTypeDfsQueryThenFetch
920 | SearchTypeDfsQueryThenFetch
@@ -922,40 +922,40 @@ data SearchType = SearchTypeQueryThenFetch
922 | SearchTypeScan
922 | SearchTypeScan
923 | SearchTypeQueryAndFetch
923 | SearchTypeQueryAndFetch
924 | SearchTypeDfsQueryAndFetch
924 | SearchTypeDfsQueryAndFetch
925− deriving (Eq, Show)
925+ deriving (Eq, Show, Generic)
927data Source =
927data Source =
929 | SourcePatterns PatternOrPatterns
929 | SourcePatterns PatternOrPatterns
930 | SourceIncludeExclude Include Exclude
930 | SourceIncludeExclude Include Exclude
931− deriving (Show, Eq)
931+ deriving (Show, Eq, Generic)
933data PatternOrPatterns = PopPattern Pattern
933data PatternOrPatterns = PopPattern Pattern
934− | PopPatterns [Pattern] deriving (Eq, Show)
934+ | PopPatterns [Pattern] deriving (Eq, Show, Generic)
936−data Include = Include [Pattern] deriving (Eq, Show)
936+data Include = Include [Pattern] deriving (Eq, Show, Generic)
937−data Exclude = Exclude [Pattern] deriving (Eq, Show)
937+data Exclude = Exclude [Pattern] deriving (Eq, Show, Generic)
939−newtype Pattern = Pattern Text deriving (Eq, Show)
939+newtype Pattern = Pattern Text deriving (Eq, Show, Generic)
941data Highlights = Highlights { globalsettings :: Maybe HighlightSettings
941data Highlights = Highlights { globalsettings :: Maybe HighlightSettings
942 , highlightFields :: [FieldHighlight]
942 , highlightFields :: [FieldHighlight]
943− } deriving (Show, Eq)
943+ } deriving (Show, Eq, Generic)
945data FieldHighlight = FieldHighlight FieldName (Maybe HighlightSettings)
945data FieldHighlight = FieldHighlight FieldName (Maybe HighlightSettings)
946− deriving (Show, Eq)
946+ deriving (Show, Eq, Generic)
949data HighlightSettings = Plain PlainHighlight
949data HighlightSettings = Plain PlainHighlight
950 | Postings PostingsHighlight
950 | Postings PostingsHighlight
951 | FastVector FastVectorHighlight
951 | FastVector FastVectorHighlight
952− deriving (Show, Eq)
952+ deriving (Show, Eq, Generic)
953data PlainHighlight =
953data PlainHighlight =
954 PlainHighlight { plainCommon :: Maybe CommonHighlight
954 PlainHighlight { plainCommon :: Maybe CommonHighlight
955− , plainNonPost :: Maybe NonPostings } deriving (Show, Eq)
955+ , plainNonPost :: Maybe NonPostings } deriving (Show, Eq, Generic)
957 -- This requires that index_options are set to 'offset' in the mapping.
957 -- 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)
960-- This requires that term_vector is set to 'with_positions_offsets' in the mapping.
960-- This requires that term_vector is set to 'with_positions_offsets' in the mapping.
961data FastVectorHighlight =
961data FastVectorHighlight =
@@ -966,7 +966,7 @@ data FastVectorHighlight =
966 , fragmentOffset :: Maybe Int
966 , fragmentOffset :: Maybe Int
967 , matchedFields :: [Text]
967 , matchedFields :: [Text]
968 , phraseLimit :: Maybe Int
968 , phraseLimit :: Maybe Int
969− } deriving (Show, Eq)
969+ } deriving (Show, Eq, Generic)
971data CommonHighlight =
971data CommonHighlight =
972 CommonHighlight { order :: Maybe Text
972 CommonHighlight { order :: Maybe Text
@@ -976,21 +976,21 @@ data CommonHighlight =
976 , noMatchSize :: Maybe Int
976 , noMatchSize :: Maybe Int
977 , highlightQuery :: Maybe Query
977 , highlightQuery :: Maybe Query
978 , requireFieldMatch :: Maybe Bool
978 , requireFieldMatch :: Maybe Bool
979− } deriving (Show, Eq)
979+ } deriving (Show, Eq, Generic)
981-- Settings that are only applicable to FastVector and Plain highlighters.
981-- Settings that are only applicable to FastVector and Plain highlighters.
982data NonPostings =
982data NonPostings =
983 NonPostings { fragmentSize :: Maybe Int
983 NonPostings { fragmentSize :: Maybe Int
984− , numberOfFragments :: Maybe Int} deriving (Show, Eq)
984+ , numberOfFragments :: Maybe Int} deriving (Show, Eq, Generic)
986data HighlightEncoder = DefaultEncoder
986data HighlightEncoder = DefaultEncoder
987 | HTMLEncoder
987 | HTMLEncoder
988− deriving (Show, Eq)
988+ deriving (Show, Eq, Generic)
990-- NOTE: Should the tags use some kind of HTML type, rather than Text?
990-- NOTE: Should the tags use some kind of HTML type, rather than Text?
991data HighlightTag = TagSchema Text
991data HighlightTag = TagSchema Text
992 | CustomTags ([Text], [Text]) -- Only uses more than the first value in the lists if fvh
992 | CustomTags ([Text], [Text]) -- Only uses more than the first value in the lists if fvh
993− deriving (Show, Eq)
993+ deriving (Show, Eq, Generic)
996data Query =
996data Query =
@@ -1021,19 +1021,19 @@ data Query =
1021 | QuerySimpleQueryStringQuery SimpleQueryStringQuery
1021 | QuerySimpleQueryStringQuery SimpleQueryStringQuery
1022 | QueryRangeQuery RangeQuery
1022 | QueryRangeQuery RangeQuery
1023 | QueryRegexpQuery RegexpQuery
1023 | QueryRegexpQuery RegexpQuery
1024− deriving (Eq, Show, Typeable)
1024+ deriving (Eq, Show, Generic, Typeable)
1026data RegexpQuery =
1026data RegexpQuery =
1027 RegexpQuery { regexpQueryField :: FieldName
1027 RegexpQuery { regexpQueryField :: FieldName
1028 , regexpQuery :: Regexp
1028 , regexpQuery :: Regexp
1029 , regexpQueryFlags :: RegexpFlags
1029 , regexpQueryFlags :: RegexpFlags
1030 , regexpQueryBoost :: Maybe Boost
1030 , regexpQueryBoost :: Maybe Boost
1031− } deriving (Eq, Show, Typeable)
1031+ } deriving (Eq, Show, Generic, Typeable)
1033data RangeQuery =
1033data RangeQuery =
1034 RangeQuery { rangeQueryField :: FieldName
1034 RangeQuery { rangeQueryField :: FieldName
1035 , rangeQueryRange :: RangeValue
1035 , rangeQueryRange :: RangeValue
1036− , rangeQueryBoost :: Boost } deriving (Eq, Show, Typeable)
1036+ , rangeQueryBoost :: Boost } deriving (Eq, Show, Generic, Typeable)
1038mkRangeQuery :: FieldName -> RangeValue -> RangeQuery
1038mkRangeQuery :: FieldName -> RangeValue -> RangeQuery
1039mkRangeQuery f r = RangeQuery f r (Boost 1.0)
1039mkRangeQuery f r = RangeQuery f r (Boost 1.0)
@@ -1047,7 +1047,7 @@ data SimpleQueryStringQuery =
1047 , simpleQueryStringFlags :: Maybe (NonEmpty SimpleQueryFlag)
1047 , simpleQueryStringFlags :: Maybe (NonEmpty SimpleQueryFlag)
1048 , simpleQueryStringLowercaseExpanded :: Maybe LowercaseExpanded
1048 , simpleQueryStringLowercaseExpanded :: Maybe LowercaseExpanded
1049 , simpleQueryStringLocale :: Maybe Locale
1049 , simpleQueryStringLocale :: Maybe Locale
1050− } deriving (Eq, Show, Typeable)
1050+ } deriving (Eq, Show, Generic, Typeable)
1052data SimpleQueryFlag =
1052data SimpleQueryFlag =
1053 SimpleQueryAll
1053 SimpleQueryAll
@@ -1061,7 +1061,7 @@ data SimpleQueryFlag =
1061 | SimpleQueryWhitespace
1061 | SimpleQueryWhitespace
1062 | SimpleQueryFuzzy
1062 | SimpleQueryFuzzy
1063 | SimpleQueryNear
1063 | SimpleQueryNear
1064− | SimpleQuerySlop deriving (Eq, Show, Typeable)
1064+ | SimpleQuerySlop deriving (Eq, Show, Generic, Typeable)
1066-- use_dis_max and tie_breaker when fields are plural?
1066-- use_dis_max and tie_breaker when fields are plural?
1067data QueryStringQuery =
1067data QueryStringQuery =
@@ -1083,7 +1083,7 @@ data QueryStringQuery =
1083 , queryStringMinimumShouldMatch :: Maybe MinimumMatch
1083 , queryStringMinimumShouldMatch :: Maybe MinimumMatch
1084 , queryStringLenient :: Maybe Lenient
1084 , queryStringLenient :: Maybe Lenient
1085 , queryStringLocale :: Maybe Locale
1085 , queryStringLocale :: Maybe Locale
1086− } deriving (Eq, Show, Typeable)
1086+ } deriving (Eq, Show, Generic, Typeable)
1088mkQueryStringQuery :: QueryString -> QueryStringQuery
1088mkQueryStringQuery :: QueryString -> QueryStringQuery
1089mkQueryStringQuery qs =
1089mkQueryStringQuery qs =
@@ -1094,19 +1094,19 @@ mkQueryStringQuery qs =
1094 Nothing Nothing
1094 Nothing Nothing
1096data FieldOrFields = FofField FieldName
1096data FieldOrFields = FofField FieldName
1097− | FofFields (NonEmpty FieldName) deriving (Eq, Show, Typeable)
1097+ | FofFields (NonEmpty FieldName) deriving (Eq, Show, Generic, Typeable)
1099data PrefixQuery =
1099data PrefixQuery =
1100 PrefixQuery
1100 PrefixQuery
1101 { prefixQueryField :: FieldName
1101 { prefixQueryField :: FieldName
1102 , prefixQueryPrefixValue :: Text
1102 , prefixQueryPrefixValue :: Text
1103− , prefixQueryBoost :: Maybe Boost } deriving (Eq, Show, Typeable)
1103+ , prefixQueryBoost :: Maybe Boost } deriving (Eq, Show, Generic, Typeable)
1105data NestedQuery =
1105data NestedQuery =
1106 NestedQuery
1106 NestedQuery
1107 { nestedQueryPath :: QueryPath
1107 { nestedQueryPath :: QueryPath
1108 , nestedQueryScoreType :: ScoreType
1108 , nestedQueryScoreType :: ScoreType
1109− , nestedQuery :: Query } deriving (Eq, Show, Typeable)
1109+ , nestedQuery :: Query } deriving (Eq, Show, Generic, Typeable)
1111data MoreLikeThisFieldQuery =
1111data MoreLikeThisFieldQuery =
1112 MoreLikeThisFieldQuery
1112 MoreLikeThisFieldQuery
@@ -1124,7 +1124,7 @@ data MoreLikeThisFieldQuery =
1124 , moreLikeThisFieldBoostTerms :: Maybe BoostTerms
1124 , moreLikeThisFieldBoostTerms :: Maybe BoostTerms
1125 , moreLikeThisFieldBoost :: Maybe Boost
1125 , moreLikeThisFieldBoost :: Maybe Boost
1126 , moreLikeThisFieldAnalyzer :: Maybe Analyzer
1126 , moreLikeThisFieldAnalyzer :: Maybe Analyzer
1127− } deriving (Eq, Show, Typeable)
1127+ } deriving (Eq, Show, Generic, Typeable)
1129data MoreLikeThisQuery =
1129data MoreLikeThisQuery =
1130 MoreLikeThisQuery
1130 MoreLikeThisQuery
@@ -1142,32 +1142,32 @@ data MoreLikeThisQuery =
1142 , moreLikeThisBoostTerms :: Maybe BoostTerms
1142 , moreLikeThisBoostTerms :: Maybe BoostTerms
1143 , moreLikeThisBoost :: Maybe Boost
1143 , moreLikeThisBoost :: Maybe Boost
1144 , moreLikeThisAnalyzer :: Maybe Analyzer
1144 , moreLikeThisAnalyzer :: Maybe Analyzer
1145− } deriving (Eq, Show, Typeable)
1145+ } deriving (Eq, Show, Generic, Typeable)
1147data IndicesQuery =
1147data IndicesQuery =
1148 IndicesQuery
1148 IndicesQuery
1149 { indicesQueryIndices :: [IndexName]
1149 { indicesQueryIndices :: [IndexName]
1150 , indicesQuery :: Query
1150 , indicesQuery :: Query
1151 -- default "all"
1151 -- default "all"
1152− , indicesQueryNoMatch :: Maybe Query } deriving (Eq, Show, Typeable)
1152+ , indicesQueryNoMatch :: Maybe Query } deriving (Eq, Show, Generic, Typeable)
1154data HasParentQuery =
1154data HasParentQuery =
1155 HasParentQuery
1155 HasParentQuery
1156 { hasParentQueryType :: TypeName
1156 { hasParentQueryType :: TypeName
1157 , hasParentQuery :: Query
1157 , hasParentQuery :: Query
1158− , hasParentQueryScoreType :: Maybe ScoreType } deriving (Eq, Show, Typeable)
1158+ , hasParentQueryScoreType :: Maybe ScoreType } deriving (Eq, Show, Generic, Typeable)
1160data HasChildQuery =
1160data HasChildQuery =
1161 HasChildQuery
1161 HasChildQuery
1162 { hasChildQueryType :: TypeName
1162 { hasChildQueryType :: TypeName
1163 , hasChildQuery :: Query
1163 , hasChildQuery :: Query
1164− , hasChildQueryScoreType :: Maybe ScoreType } deriving (Eq, Show, Typeable)
1164+ , hasChildQueryScoreType :: Maybe ScoreType } deriving (Eq, Show, Generic, Typeable)
1166data ScoreType =
1166data ScoreType =
1167 ScoreTypeMax
1167 ScoreTypeMax
1168 | ScoreTypeSum
1168 | ScoreTypeSum
1169 | ScoreTypeAvg
1169 | ScoreTypeAvg
1170− | ScoreTypeNone deriving (Eq, Show, Typeable)
1170+ | ScoreTypeNone deriving (Eq, Show, Generic, Typeable)
1172data FuzzyQuery =
1172data FuzzyQuery =
1173 FuzzyQuery { fuzzyQueryField :: FieldName
1173 FuzzyQuery { fuzzyQueryField :: FieldName
@@ -1176,7 +1176,7 @@ data FuzzyQuery =
1176 , fuzzyQueryMaxExpansions :: MaxExpansions
1176 , fuzzyQueryMaxExpansions :: MaxExpansions
1177 , fuzzyQueryFuzziness :: Fuzziness
1177 , fuzzyQueryFuzziness :: Fuzziness
1178 , fuzzyQueryBoost :: Maybe Boost
1178 , fuzzyQueryBoost :: Maybe Boost
1179− } deriving (Eq, Show, Typeable)
1179+ } deriving (Eq, Show, Generic, Typeable)
1181data FuzzyLikeFieldQuery =
1181data FuzzyLikeFieldQuery =
1182 FuzzyLikeFieldQuery
1182 FuzzyLikeFieldQuery
@@ -1189,7 +1189,7 @@ data FuzzyLikeFieldQuery =
1189 , fuzzyLikeFieldPrefixLength :: PrefixLength
1189 , fuzzyLikeFieldPrefixLength :: PrefixLength
1190 , fuzzyLikeFieldBoost :: Boost
1190 , fuzzyLikeFieldBoost :: Boost
1191 , fuzzyLikeFieldAnalyzer :: Maybe Analyzer
1191 , fuzzyLikeFieldAnalyzer :: Maybe Analyzer
1192− } deriving (Eq, Show, Typeable)
1192+ } deriving (Eq, Show, Generic, Typeable)
1194data FuzzyLikeThisQuery =
1194data FuzzyLikeThisQuery =
1195 FuzzyLikeThisQuery
1195 FuzzyLikeThisQuery
@@ -1201,19 +1201,19 @@ data FuzzyLikeThisQuery =
1201 , fuzzyLikePrefixLength :: PrefixLength
1201 , fuzzyLikePrefixLength :: PrefixLength
1202 , fuzzyLikeBoost :: Boost
1202 , fuzzyLikeBoost :: Boost
1203 , fuzzyLikeAnalyzer :: Maybe Analyzer
1203 , fuzzyLikeAnalyzer :: Maybe Analyzer
1204− } deriving (Eq, Show, Typeable)
1204+ } deriving (Eq, Show, Generic, Typeable)
1206data FilteredQuery =
1206data FilteredQuery =
1207 FilteredQuery
1207 FilteredQuery
1208 { filteredQuery :: Query
1208 { filteredQuery :: Query
1209− , filteredFilter :: Filter } deriving (Eq, Show, Typeable)
1209+ , filteredFilter :: Filter } deriving (Eq, Show, Generic, Typeable)
1211data DisMaxQuery =
1211data DisMaxQuery =
1212 DisMaxQuery { disMaxQueries :: [Query]
1212 DisMaxQuery { disMaxQueries :: [Query]
1213 -- default 0.0
1213 -- default 0.0
1214 , disMaxTiebreaker :: Tiebreaker
1214 , disMaxTiebreaker :: Tiebreaker
1215 , disMaxBoost :: Maybe Boost
1215 , disMaxBoost :: Maybe Boost
1216− } deriving (Eq, Show, Typeable)
1216+ } deriving (Eq, Show, Generic, Typeable)
1218data MatchQuery =
1218data MatchQuery =
1219 MatchQuery { matchQueryField :: FieldName
1219 MatchQuery { matchQueryField :: FieldName
@@ -1225,7 +1225,7 @@ data MatchQuery =
1225 , matchQueryAnalyzer :: Maybe Analyzer
1225 , matchQueryAnalyzer :: Maybe Analyzer
1226 , matchQueryMaxExpansions :: Maybe MaxExpansions
1226 , matchQueryMaxExpansions :: Maybe MaxExpansions
1227 , matchQueryLenient :: Maybe Lenient
1227 , matchQueryLenient :: Maybe Lenient
1228− , matchQueryBoost :: Maybe Boost } deriving (Eq, Show, Typeable)
1228+ , matchQueryBoost :: Maybe Boost } deriving (Eq, Show, Generic, Typeable)
1230{-| 'mkMatchQuery' is a convenience function that defaults the less common parameters,
1230{-| 'mkMatchQuery' is a convenience function that defaults the less common parameters,
1231 enabling you to provide only the 'FieldName' and 'QueryString' to make a 'MatchQuery'
1231 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
1236data MatchQueryType =
1236data MatchQueryType =
1237 MatchPhrase
1237 MatchPhrase
1238− | MatchPhrasePrefix deriving (Eq, Show, Typeable)
1238+ | MatchPhrasePrefix deriving (Eq, Show, Generic, Typeable)
1240data MultiMatchQuery =
1240data MultiMatchQuery =
1241 MultiMatchQuery { multiMatchQueryFields :: [FieldName]
1241 MultiMatchQuery { multiMatchQueryFields :: [FieldName]
@@ -1247,7 +1247,7 @@ data MultiMatchQuery =
1247 , multiMatchQueryCutoffFrequency :: Maybe CutoffFrequency
1247 , multiMatchQueryCutoffFrequency :: Maybe CutoffFrequency
1248 , multiMatchQueryAnalyzer :: Maybe Analyzer
1248 , multiMatchQueryAnalyzer :: Maybe Analyzer
1249 , multiMatchQueryMaxExpansions :: Maybe MaxExpansions
1249 , multiMatchQueryMaxExpansions :: Maybe MaxExpansions
1250− , multiMatchQueryLenient :: Maybe Lenient } deriving (Eq, Show, Typeable)
1250+ , multiMatchQueryLenient :: Maybe Lenient } deriving (Eq, Show, Generic, Typeable)
1252{-| 'mkMultiMatchQuery' is a convenience function that defaults the less common parameters,
1252{-| 'mkMultiMatchQuery' is a convenience function that defaults the less common parameters,
1253 enabling you to provide only the list of 'FieldName's and 'QueryString' to
1253 enabling you to provide only the list of 'FieldName's and 'QueryString' to
@@ -1264,7 +1264,7 @@ data MultiMatchQueryType =
1264 | MultiMatchMostFields
1264 | MultiMatchMostFields
1265 | MultiMatchCrossFields
1265 | MultiMatchCrossFields
1266 | MultiMatchPhrase
1266 | MultiMatchPhrase
1267− | MultiMatchPhrasePrefix deriving (Eq, Show, Typeable)
1267+ | MultiMatchPhrasePrefix deriving (Eq, Show, Generic, Typeable)
1269data BoolQuery =
1269data BoolQuery =
1270 BoolQuery { boolQueryMustMatch :: [Query]
1270 BoolQuery { boolQueryMustMatch :: [Query]
@@ -1273,7 +1273,7 @@ data BoolQuery =
1273 , boolQueryMinimumShouldMatch :: Maybe MinimumMatch
1273 , boolQueryMinimumShouldMatch :: Maybe MinimumMatch
1274 , boolQueryBoost :: Maybe Boost
1274 , boolQueryBoost :: Maybe Boost
1275 , boolQueryDisableCoord :: Maybe DisableCoord
1275 , boolQueryDisableCoord :: Maybe DisableCoord
1276− } deriving (Eq, Show, Typeable)
1276+ } deriving (Eq, Show, Generic, Typeable)
1278mkBoolQuery :: [Query] -> [Query] -> [Query] -> BoolQuery
1278mkBoolQuery :: [Query] -> [Query] -> [Query] -> BoolQuery
1279mkBoolQuery must mustNot should =
1279mkBoolQuery must mustNot should =
@@ -1282,7 +1282,7 @@ mkBoolQuery must mustNot should =
1282data BoostingQuery =
1282data BoostingQuery =
1283 BoostingQuery { positiveQuery :: Query
1283 BoostingQuery { positiveQuery :: Query
1284 , negativeQuery :: Query
1284 , negativeQuery :: Query
1285− , negativeBoost :: Boost } deriving (Eq, Show, Typeable)
1285+ , negativeBoost :: Boost } deriving (Eq, Show, Generic, Typeable)
1287data CommonTermsQuery =
1287data CommonTermsQuery =
1288 CommonTermsQuery { commonField :: FieldName
1288 CommonTermsQuery { commonField :: FieldName
@@ -1294,16 +1294,16 @@ data CommonTermsQuery =
1294 , commonBoost :: Maybe Boost
1294 , commonBoost :: Maybe Boost
1295 , commonAnalyzer :: Maybe Analyzer
1295 , commonAnalyzer :: Maybe Analyzer
1296 , commonDisableCoord :: Maybe DisableCoord
1296 , commonDisableCoord :: Maybe DisableCoord
1297− } deriving (Eq, Show, Typeable)
1297+ } deriving (Eq, Show, Generic, Typeable)
1299data CommonMinimumMatch =
1299data CommonMinimumMatch =
1300 CommonMinimumMatchHighLow MinimumMatchHighLow
1300 CommonMinimumMatchHighLow MinimumMatchHighLow
1301 | CommonMinimumMatch MinimumMatch
1301 | CommonMinimumMatch MinimumMatch
1302− deriving (Eq, Show, Typeable)
1302+ deriving (Eq, Show, Generic, Typeable)
1304data MinimumMatchHighLow =
1304data MinimumMatchHighLow =
1305 MinimumMatchHighLow { lowFreq :: MinimumMatch
1305 MinimumMatchHighLow { lowFreq :: MinimumMatch
1306− , highFreq :: MinimumMatch } deriving (Eq, Show, Typeable)
1306+ , highFreq :: MinimumMatch } deriving (Eq, Show, Generic, Typeable)
1308data Filter = AndFilter [Filter] Cache
1308data Filter = AndFilter [Filter] Cache
1309 | OrFilter [Filter] Cache
1309 | OrFilter [Filter] Cache
@@ -1323,36 +1323,36 @@ data Filter = AndFilter [Filter] Cache
1323 | RangeFilter FieldName RangeValue RangeExecution Cache
1323 | RangeFilter FieldName RangeValue RangeExecution Cache
1324 | RegexpFilter FieldName Regexp RegexpFlags CacheName Cache CacheKey
1324 | RegexpFilter FieldName Regexp RegexpFlags CacheName Cache CacheKey
1325 | TermFilter Term Cache
1325 | TermFilter Term Cache
1326− deriving (Eq, Show, Typeable)
1326+ deriving (Eq, Show, Generic, Typeable)
1328data ZeroTermsQuery = ZeroTermsNone
1328data ZeroTermsQuery = ZeroTermsNone
1329− | ZeroTermsAll deriving (Eq, Show, Typeable)
1329+ | ZeroTermsAll deriving (Eq, Show, Generic, Typeable)
1331data RangeExecution = RangeExecutionIndex
1331data RangeExecution = RangeExecutionIndex
1332− | RangeExecutionFielddata deriving (Eq, Show, Typeable)
1332+ | RangeExecutionFielddata deriving (Eq, Show, Generic, Typeable)
1334−newtype Regexp = Regexp Text deriving (Eq, Show, FromJSON)
1334+newtype Regexp = Regexp Text deriving (Eq, Show, Generic, FromJSON)
1336data RegexpFlags = AllRegexpFlags
1336data RegexpFlags = AllRegexpFlags
1337 | NoRegexpFlags
1337 | NoRegexpFlags
1338− | SomeRegexpFlags (NonEmpty RegexpFlag) deriving (Eq, Show)
1338+ | SomeRegexpFlags (NonEmpty RegexpFlag) deriving (Eq, Show, Generic)
1340data RegexpFlag = AnyString
1340data RegexpFlag = AnyString
1341 | Automaton
1341 | Automaton
1342 | Complement
1342 | Complement
1344 | Intersection
1344 | Intersection
1345− | Interval deriving (Eq, Show)
1345+ | Interval deriving (Eq, Show, Generic)
1347−newtype LessThan = LessThan Double deriving (Eq, Show)
1347+newtype LessThan = LessThan Double deriving (Eq, Show, Generic)
1348−newtype LessThanEq = LessThanEq Double deriving (Eq, Show)
1348+newtype LessThanEq = LessThanEq Double deriving (Eq, Show, Generic)
1349−newtype GreaterThan = GreaterThan Double deriving (Eq, Show)
1349+newtype GreaterThan = GreaterThan Double deriving (Eq, Show, Generic)
1350−newtype GreaterThanEq = GreaterThanEq Double deriving (Eq, Show)
1350+newtype GreaterThanEq = GreaterThanEq Double deriving (Eq, Show, Generic)
1352−newtype LessThanD = LessThanD UTCTime deriving (Eq, Show)
1352+newtype LessThanD = LessThanD UTCTime deriving (Eq, Show, Generic)
1353−newtype LessThanEqD = LessThanEqD UTCTime deriving (Eq, Show)
1353+newtype LessThanEqD = LessThanEqD UTCTime deriving (Eq, Show, Generic)
1354−newtype GreaterThanD = GreaterThanD UTCTime deriving (Eq, Show)
1354+newtype GreaterThanD = GreaterThanD UTCTime deriving (Eq, Show, Generic)
1355−newtype GreaterThanEqD = GreaterThanEqD UTCTime deriving (Eq, Show)
1355+newtype GreaterThanEqD = GreaterThanEqD UTCTime deriving (Eq, Show, Generic)
1357data RangeValue = RangeDateLte LessThanEqD
1357data RangeValue = RangeDateLte LessThanEqD
1358 | RangeDateLt LessThanD
1358 | RangeDateLt LessThanD
@@ -1370,7 +1370,7 @@ data RangeValue = RangeDateLte LessThanEqD
1370 | RangeDoubleGteLte GreaterThanEq LessThanEq
1370 | RangeDoubleGteLte GreaterThanEq LessThanEq
1371 | RangeDoubleGteLt GreaterThanEq LessThan
1371 | RangeDoubleGteLt GreaterThanEq LessThan
1372 | RangeDoubleGtLte GreaterThan LessThanEq
1372 | RangeDoubleGtLte GreaterThan LessThanEq
1373− deriving (Eq, Show)
1373+ deriving (Eq, Show, Generic)
1375rangeValueToPair :: RangeValue -> [Pair]
1375rangeValueToPair :: RangeValue -> [Pair]
1376rangeValueToPair rv = case rv of
1376rangeValueToPair rv = case rv of
@@ -1392,33 +1392,33 @@ rangeValueToPair rv = case rv of
1392 RangeDoubleGtLt (GreaterThan l) (LessThan g) -> ["gt" .= l, "lt" .= g]
1392 RangeDoubleGtLt (GreaterThan l) (LessThan g) -> ["gt" .= l, "lt" .= g]
1394data Term = Term { termField :: Text
1394data Term = Term { termField :: Text
1395− , termValue :: Text } deriving (Eq, Show, Typeable)
1395+ , termValue :: Text } deriving (Eq, Show, Generic, Typeable)
1397data BoolMatch = MustMatch Term Cache
1397data BoolMatch = MustMatch Term Cache
1398 | MustNotMatch Term Cache
1398 | MustNotMatch Term Cache
1399− | ShouldMatch [Term] Cache deriving (Eq, Show, Typeable)
1399+ | ShouldMatch [Term] Cache deriving (Eq, Show, Generic, Typeable)
1401-- "memory" or "indexed"
1401-- "memory" or "indexed"
1402data GeoFilterType = GeoFilterMemory
1402data GeoFilterType = GeoFilterMemory
1403− | GeoFilterIndexed deriving (Eq, Show, Typeable)
1403+ | GeoFilterIndexed deriving (Eq, Show, Generic, Typeable)
1405data LatLon = LatLon { lat :: Double
1405data LatLon = LatLon { lat :: Double
1406− , lon :: Double } deriving (Eq, Show, Typeable)
1406+ , lon :: Double } deriving (Eq, Show, Generic, Typeable)
1408data GeoBoundingBox =
1408data GeoBoundingBox =
1409 GeoBoundingBox { topLeft :: LatLon
1409 GeoBoundingBox { topLeft :: LatLon
1410− , bottomRight :: LatLon } deriving (Eq, Show, Typeable)
1410+ , bottomRight :: LatLon } deriving (Eq, Show, Generic, Typeable)
1412data GeoBoundingBoxConstraint =
1412data GeoBoundingBoxConstraint =
1413 GeoBoundingBoxConstraint { geoBBField :: FieldName
1413 GeoBoundingBoxConstraint { geoBBField :: FieldName
1414 , constraintBox :: GeoBoundingBox
1414 , constraintBox :: GeoBoundingBox
1415 , bbConstraintcache :: Cache
1415 , bbConstraintcache :: Cache
1416 , geoType :: GeoFilterType
1416 , geoType :: GeoFilterType
1417− } deriving (Eq, Show, Typeable)
1417+ } deriving (Eq, Show, Generic, Typeable)
1419data GeoPoint =
1419data GeoPoint =
1420 GeoPoint { geoField :: FieldName
1420 GeoPoint { geoField :: FieldName
1421− , latLon :: LatLon} deriving (Eq, Show, Typeable)
1421+ , latLon :: LatLon} deriving (Eq, Show, Generic, Typeable)
1423data DistanceUnit = Miles
1423data DistanceUnit = Miles
@@ -1428,22 +1428,22 @@ data DistanceUnit = Miles
1428 | Meters
1428 | Meters
1429 | Centimeters
1429 | Centimeters
1430 | Millimeters
1430 | Millimeters
1431− | NauticalMiles deriving (Eq, Show, Typeable)
1431+ | NauticalMiles deriving (Eq, Show, Generic, Typeable)
1433data DistanceType = Arc
1433data DistanceType = Arc
1434 | SloppyArc -- doesn't exist <1.0
1434 | SloppyArc -- doesn't exist <1.0
1435− | Plane deriving (Eq, Show, Typeable)
1435+ | Plane deriving (Eq, Show, Generic, Typeable)
1437data OptimizeBbox = OptimizeGeoFilterType GeoFilterType
1437data OptimizeBbox = OptimizeGeoFilterType GeoFilterType
1438− | NoOptimizeBbox deriving (Eq, Show, Typeable)
1438+ | NoOptimizeBbox deriving (Eq, Show, Generic, Typeable)
1440data Distance =
1440data Distance =
1441 Distance { coefficient :: Double
1441 Distance { coefficient :: Double
1442− , unit :: DistanceUnit } deriving (Eq, Show, Typeable)
1442+ , unit :: DistanceUnit } deriving (Eq, Show, Generic, Typeable)
1444data DistanceRange =
1444data DistanceRange =
1445 DistanceRange { distanceFrom :: Distance
1445 DistanceRange { distanceFrom :: Distance
1446− , distanceTo :: Distance } deriving (Eq, Show)
1446+ , distanceTo :: Distance } deriving (Eq, Show, Generic)
1448data SearchResult a =
1448data SearchResult a =
1449 SearchResult { took :: Int
1449 SearchResult { took :: Int
@@ -1451,16 +1451,16 @@ data SearchResult a =
1451 , shards :: ShardResult
1451 , shards :: ShardResult
1452 , searchHits :: SearchHits a
1452 , searchHits :: SearchHits a
1453 , aggregations :: Maybe AggregationResults
1453 , aggregations :: Maybe AggregationResults
1454− , scrollId :: Maybe ScrollId } deriving (Eq, Show)
1454+ , scrollId :: Maybe ScrollId } deriving (Eq, Show, Generic)
1456−newtype ScrollId = ScrollId Text deriving (Eq, Show, Ord, ToJSON, FromJSON)
1456+newtype ScrollId = ScrollId Text deriving (Eq, Show, Generic, Ord, ToJSON, FromJSON)
1458type Score = Maybe Double
1458type Score = Maybe Double
1460data SearchHits a =
1460data SearchHits a =
1461 SearchHits { hitsTotal :: Int
1461 SearchHits { hitsTotal :: Int
1462 , maxScore :: Score
1462 , maxScore :: Score
1463− , hits :: [Hit a] } deriving (Eq, Show)
1463+ , hits :: [Hit a] } deriving (Eq, Show, Generic)
1466instance Monoid (SearchHits a) where
1466instance Monoid (SearchHits a) where
@@ -1475,7 +1475,7 @@ data Hit a =
1475 , hitDocId :: DocId
1475 , hitDocId :: DocId
1476 , hitScore :: Score
1476 , hitScore :: Score
1477 , hitSource :: Maybe a
1477 , hitSource :: Maybe a
1478− , hitHighlight :: Maybe HitHighlight } deriving (Eq, Show)
1478+ , hitHighlight :: Maybe HitHighlight } deriving (Eq, Show, Generic)
1480data ShardResult =
1480data ShardResult =
1481 ShardResult { shardTotal :: Int
1481 ShardResult { shardTotal :: Int
@@ -1504,19 +1504,19 @@ mkAggregations :: Text -> Aggregation -> Aggregations
1504mkAggregations name aggregation = M.insert name aggregation emptyAggregations
1504mkAggregations name aggregation = M.insert name aggregation emptyAggregations
1506data TermOrder = TermOrder{ termSortField :: Text
1506data TermOrder = TermOrder{ termSortField :: Text
1507− , termSortOrder :: SortOrder } deriving (Eq, Show)
1507+ , termSortOrder :: SortOrder } deriving (Eq, Show, Generic)
1509data TermInclusion = TermInclusion Text
1509data TermInclusion = TermInclusion Text
1510− | TermPattern Text Text deriving (Eq, Show)
1510+ | TermPattern Text Text deriving (Eq, Show, Generic)
1512data CollectionMode = BreadthFirst
1512data CollectionMode = BreadthFirst
1513− | DepthFirst deriving (Eq, Show)
1513+ | DepthFirst deriving (Eq, Show, Generic)
1515data ExecutionHint = Ordinals
1515data ExecutionHint = Ordinals
1516 | GlobalOrdinals
1516 | GlobalOrdinals
1517 | GlobalOrdinalsHash
1517 | GlobalOrdinalsHash
1518 | GlobalOrdinalsLowCardinality
1518 | GlobalOrdinalsLowCardinality
1519− | Map deriving (Eq, Show)
1519+ | Map deriving (Eq, Show, Generic)
1521data TimeInterval = Weeks
1521data TimeInterval = Weeks
@@ -1532,13 +1532,13 @@ data Interval = Year
1533 | Minute
1533 | Minute
1534 | Second
1534 | Second
1535− | FractionalInterval Float TimeInterval deriving (Eq, Show)
1535+ | FractionalInterval Float TimeInterval deriving (Eq, Show, Generic)
1537data Aggregation = TermsAgg TermsAggregation
1537data Aggregation = TermsAgg TermsAggregation
1538 | DateHistogramAgg DateHistogramAggregation
1538 | DateHistogramAgg DateHistogramAggregation
1539 | ValueCountAgg ValueCountAggregation
1539 | ValueCountAgg ValueCountAggregation
1540 | FilterAgg FilterAggregation
1540 | FilterAgg FilterAggregation
1541− | DateRangeAgg DateRangeAggregation deriving (Eq, Show)
1541+ | DateRangeAgg DateRangeAggregation deriving (Eq, Show, Generic)
1544data TermsAggregation = TermsAggregation { term :: Either Text Text
1544data TermsAggregation = TermsAggregation { term :: Either Text Text
@@ -1551,7 +1551,7 @@ data TermsAggregation = TermsAggregation { term :: Either Text Text
1551 , termCollectMode :: Maybe CollectionMode
1551 , termCollectMode :: Maybe CollectionMode
1552 , termExecutionHint :: Maybe ExecutionHint
1552 , termExecutionHint :: Maybe ExecutionHint
1553 , termAggs :: Maybe Aggregations
1553 , termAggs :: Maybe Aggregations
1554− } deriving (Eq, Show)
1554+ } deriving (Eq, Show, Generic)
1556data DateHistogramAggregation = DateHistogramAggregation { dateField :: FieldName
1556data DateHistogramAggregation = DateHistogramAggregation { dateField :: FieldName
1557 , dateInterval :: Interval
1557 , dateInterval :: Interval
@@ -1562,29 +1562,29 @@ data DateHistogramAggregation = DateHistogramAggregation { dateField :: Fie
1562 , datePreOffset :: Maybe Text
1562 , datePreOffset :: Maybe Text
1563 , datePostOffset :: Maybe Text
1563 , datePostOffset :: Maybe Text
1564 , dateAggs :: Maybe Aggregations
1564 , dateAggs :: Maybe Aggregations
1565− } deriving (Eq, Show)
1565+ } deriving (Eq, Show, Generic)
1568data DateRangeAggregation = DateRangeAggregation { draField :: FieldName
1568data DateRangeAggregation = DateRangeAggregation { draField :: FieldName
1569 , draFormat :: Maybe Text
1569 , draFormat :: Maybe Text
1570 , draRanges :: NonEmpty DateRangeAggRange
1570 , draRanges :: NonEmpty DateRangeAggRange
1571− } deriving (Eq, Show)
1571+ } deriving (Eq, Show, Generic)
1573data DateRangeAggRange = DateRangeFrom DateMathExpr
1573data DateRangeAggRange = DateRangeFrom DateMathExpr
1574 | DateRangeTo DateMathExpr
1574 | DateRangeTo DateMathExpr
1575− | DateRangeFromAndTo DateMathExpr DateMathExpr deriving (Eq, Show)
1575+ | DateRangeFromAndTo DateMathExpr DateMathExpr deriving (Eq, Show, Generic)
1577-- | See <https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math> for more information.
1577-- | 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)
1581-- | Starting point for a date range. This along with the 'DateMathModifiers' gets you the date ES will start from.
1581-- | Starting point for a date range. This along with the 'DateMathModifiers' gets you the date ES will start from.
1582data DateMathAnchor = DMNow
1582data DateMathAnchor = DMNow
1583− | DMDate Day deriving (Eq, Show)
1583+ | DMDate Day deriving (Eq, Show, Generic)
1585data DateMathModifier = AddTime Int DateMathUnit
1585data DateMathModifier = AddTime Int DateMathUnit
1586 | SubtractTime Int DateMathUnit
1586 | SubtractTime Int DateMathUnit
1587− | RoundDownTo DateMathUnit deriving (Eq, Show)
1587+ | RoundDownTo DateMathUnit deriving (Eq, Show, Generic)
1589data DateMathUnit = DMYear
1589data DateMathUnit = DMYear
1590 | DMMonth
1590 | DMMonth
@@ -1592,15 +1592,15 @@ data DateMathUnit = DMYear
1593 | DMHour
1593 | DMHour
1594 | DMMinute
1594 | DMMinute
1595− | DMSecond deriving (Eq, Show)
1595+ | DMSecond deriving (Eq, Show, Generic)
1597-- | See <https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-valuecount-aggregation.html> for more information.
1597-- | See <https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-valuecount-aggregation.html> for more information.
1598data ValueCountAggregation = FieldValueCount FieldName
1598data ValueCountAggregation = FieldValueCount FieldName
1599− | ScriptValueCount Script deriving (Eq, Show)
1599+ | ScriptValueCount Script deriving (Eq, Show, Generic)
1601-- | 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.
1601-- | 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.
1602data FilterAggregation = FilterAggregation { faFilter :: Filter
1602data FilterAggregation = FilterAggregation { faFilter :: Filter
1603− , faAggs :: Maybe Aggregations} deriving (Eq, Show)
1603+ , faAggs :: Maybe Aggregations} deriving (Eq, Show, Generic)
1605mkTermsAggregation :: Text -> TermsAggregation
1605mkTermsAggregation :: Text -> TermsAggregation
1606mkTermsAggregation t = TermsAggregation (Left t) Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
1606mkTermsAggregation t = TermsAggregation (Left t) Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
@@ -1756,7 +1756,7 @@ data DateRangeResult = DateRangeResult { dateRangeKey :: Text
1756 , dateRangeTo :: Maybe UTCTime
1756 , dateRangeTo :: Maybe UTCTime
1757 , dateRangeToAsString :: Maybe Text
1757 , dateRangeToAsString :: Maybe Text
1758 , dateRangeDocCount :: Int
1758 , dateRangeDocCount :: Int
1759− , dateRangeAggs :: Maybe AggregationResults } deriving (Show, Eq)
1759+ , dateRangeAggs :: Maybe AggregationResults } deriving (Show, Eq, Generic)
1761toTerms :: Text -> AggregationResults -> Maybe (Bucket TermsResult)
1761toTerms :: Text -> AggregationResults -> Maybe (Bucket TermsResult)
1762toTerms t a = M.lookup t a >>= deserialize
1762toTerms t a = M.lookup t a >>= deserialize
@@ -2861,7 +2861,7 @@ instance FromJSON UpdatableIndexSetting where
2861 <|> blocksWrite `taggedAt` ["blocks", "write"]
2861 <|> blocksWrite `taggedAt` ["blocks", "write"]
2862 <|> blocksMetaData `taggedAt` ["blocks", "metadata"]
2862 <|> blocksMetaData `taggedAt` ["blocks", "metadata"]
2863 where taggedAt f ks = taggedAt' f (Object o) ks
2863 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))
2865 taggedAt' f v (k:ks) = withObject "Object" (\o -> do v' <- o .: k
2865 taggedAt' f v (k:ks) = withObject "Object" (\o -> do v' <- o .: k
2866 taggedAt' f v' ks) v
2866 taggedAt' f v' ks) v
2867 numberOfReplicas = pure . NumberOfReplicas
2867 numberOfReplicas = pure . NumberOfReplicas
@@ -2896,10 +2896,37 @@ instance FromJSON UpdatableIndexSetting where
2896instance FromJSON IndexSettingsSummary where
2896instance FromJSON IndexSettingsSummary where
2897 parseJSON = withObject "IndexSettingsSummary" parse
2897 parseJSON = withObject "IndexSettingsSummary" parse
2898 where parse o = case HM.toList o of
2898 where parse o = case HM.toList o of
2899− [(ixn, v)] -> IndexSettingsSummary (IndexName ixn)
2899+ [(ixn, v@(Object o'))] -> IndexSettingsSummary (IndexName ixn)
2900− <$> parseJSON v
2900+ <$> parseJSON v
2901− <*> parseJSON v
2901+ <*> (fmap (filter (not . redundant)) . parseSettings =<< o' .: "settings")
2902 _ -> fail "Expected single-key object with index name"
2902 _ -> fail "Expected single-key object with index name"
2903+ redundant (NumberOfReplicas _) = True
2904+ redundant _ = False
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)
2917+unStringlyTypeJSON _ = mzero
2920+parseSettings :: Object -> Parser [UpdatableIndexSetting]
2921+parseSettings o = do
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)
2904oPath :: ToJSON a => NonEmpty Text -> a -> Value
2931oPath :: ToJSON a => NonEmpty Text -> a -> Value
2905oPath (k :| []) v = object [k .= v]
2932oPath (k :| []) v = object [k .= v]
@@ -2989,7 +3016,7 @@ instance ToJSON NominalDiffTimeJSON where
2989instance FromJSON NominalDiffTimeJSON where
3016instance FromJSON NominalDiffTimeJSON where
2990 parseJSON = withText "NominalDiffTime" parse
3017 parseJSON = withText "NominalDiffTime" parse
2991 where parse t = case T.takeEnd 1 t of
3018 where parse t = case T.takeEnd 1 t of
2992− "s" -> NominalDiffTimeJSON . fromInteger <$> parseReadText t
3019+ "s" -> NominalDiffTimeJSON . fromInteger <$> parseReadText (T.dropEnd 1 t)
2993 _ -> fail "Invalid or missing NominalDiffTime unit (expected s)"
3020 _ -> fail "Invalid or missing NominalDiffTime unit (expected s)"
2995instance ToJSON IndexTemplate where
3022instance ToJSON IndexTemplate where
@@ -3477,6 +3504,19 @@ instance FromJSON DocVersion where
3477 i <- parseJSON v
3504 i <- parseJSON v
3478 maybe (fail "DocVersion out of range") return $ mkDocVersion i
3505 maybe (fail "DocVersion out of range") return $ mkDocVersion i
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)
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)
3480instance Bounded DocVersion where
3520instance Bounded DocVersion where
3481 minBound = DocVersion 1
3521 minBound = DocVersion 1
3482 maxBound = DocVersion 9200000000000000000 -- 9.2e+18
3522 maxBound = DocVersion 9200000000000000000 -- 9.2e+18