@@ -305,6 +305,7 @@ import GHC.Enum
305305import GHC.Generics (Generic)
306306import Network.HTTP.Client
307307import qualified Network.HTTP.Types.Method as NHTM
308+import qualified Text.Read as TR
308309
309310import Database.Bloodhound.Types.Class
310311import Database.Bloodhound.Types.Internal
@@ -363,7 +364,7 @@ data Version = Version { number :: Text
363364 , build_hash :: Text
364365 , build_timestamp :: UTCTime
365366 , build_snapshot :: Bool
366− , lucene_version :: Text } deriving (Eq, Show, Generic, Typeable)
367+ , lucene_version :: Text } deriving (Eq, Read, Show, Generic, Typeable)
367368
368369{-| 'Status' is a data type for describing the JSON body returned by
369370 Elasticsearch when you query its status. This was deprecated in 1.2.0.
@@ -375,7 +376,7 @@ data Status = Status { ok :: Maybe Bool
375376 , status :: Int
376377 , name :: Text
377378 , version :: Version
378− , tagline :: Text } deriving (Eq, Show, Generic)
379+ , tagline :: Text } deriving (Eq, Read, Show, Generic)
379380
380381{-| 'IndexSettings' is used to configure the shards and replicas when you create
381382 an Elasticsearch Index.
@@ -385,7 +386,7 @@ data Status = Status { ok :: Maybe Bool
385386
386387data IndexSettings =
387388 IndexSettings { indexShards :: ShardCount
388− , indexReplicas :: ReplicaCount } deriving (Eq, Show, Generic, Typeable)
389+ , indexReplicas :: ReplicaCount } deriving (Eq, Read, Show, Generic, Typeable)
389390
390391{-| 'defaultIndexSettings' is an 'IndexSettings' with 3 shards and 2 replicas. -}
391392defaultIndexSettings :: IndexSettings
@@ -475,35 +476,35 @@ data AllocationPolicy = AllocAll
475476 -- ^ Allows shard allocation only for primary shards for new indices.
476477 | AllocNone
477478 -- ^ No shard allocation is allowed
478− deriving (Eq, Show, Generic, Typeable)
479+ deriving (Eq, Read, Show, Generic, Typeable)
479480
480481data ReplicaBounds = ReplicasBounded Int Int
481482 | ReplicasLowerBounded Int
482483 | ReplicasUnbounded
483− deriving (Eq, Show, Generic, Typeable)
484+ deriving (Eq, Read, Show, Generic, Typeable)
484485
485−newtype Bytes = Bytes Int deriving (Eq, Show, Generic, Typeable, Ord, ToJSON, FromJSON)
486+newtype Bytes = Bytes Int deriving (Eq, Read, Show, Generic, Typeable, Ord, ToJSON, FromJSON)
486487
487488data FSType = FSSimple
488− | FSBuffered deriving (Eq, Show, Generic, Typeable, Ord)
489+ | FSBuffered deriving (Eq, Read, Show, Generic, Typeable, Ord)
489490
490491data InitialShardCount = QuorumShards
491492 | QuorumMinus1Shards
492493 | FullShards
493494 | FullMinus1Shards
494495 | ExplicitShards Int
495− deriving (Eq, Show, Generic, Typeable)
496+ deriving (Eq, Read, Show, Generic, Typeable)
496497
497498data NodeAttrFilter = NodeAttrFilter { nodeAttrFilterName :: NodeAttrName
498499 , nodeAttrFilterValues :: NonEmpty Text}
499− deriving (Eq, Show, Generic, Ord)
500+ deriving (Eq, Read, Show, Generic, Ord)
500501
501−newtype NodeAttrName = NodeAttrName Text deriving (Eq, Show, Ord, Generic, Typeable)
502+newtype NodeAttrName = NodeAttrName Text deriving (Eq, Read, Show, Ord, Generic, Typeable)
502503
503504data CompoundFormat = CompoundFileFormat Bool
504505 | MergeSegmentVsTotalIndex Double
505506 -- ^ percentage between 0 and 1 where 0 is false, 1 is true
506− deriving (Eq, Show, Generic, Typeable)
507+ deriving (Eq, Read, Show, Generic, Typeable)
507508
508509newtype NominalDiffTimeJSON = NominalDiffTimeJSON { ndtJSON :: NominalDiffTime }
509510
@@ -520,7 +521,7 @@ type Method = NHTM.Method
520521
521522 <http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-open-close.html>
522523-}
523−data OpenCloseIndex = OpenIndex | CloseIndex deriving (Eq, Show, Generic, Typeable)
524+data OpenCloseIndex = OpenIndex | CloseIndex deriving (Eq, Read, Show, Generic, Typeable)
524525
525526data FieldType = GeoPointType
526527 | GeoShapeType
@@ -528,10 +529,10 @@ data FieldType = GeoPointType
528529 | IntegerType
529530 | LongType
530531 | ShortType
531− | ByteType deriving (Eq, Show, Generic, Typeable)
532+ | ByteType deriving (Eq, Read, Show, Generic, Typeable)
532533
533534data FieldDefinition =
534− FieldDefinition { fieldType :: FieldType } deriving (Eq, Show, Generic, Typeable)
535+ FieldDefinition { fieldType :: FieldType } deriving (Eq, Read, Show, Generic, Typeable)
535536
536537{-| An 'IndexTemplate' defines a template that will automatically be
537538 applied to new indices created. The templates include both
@@ -549,7 +550,7 @@ data IndexTemplate =
549550
550551data MappingField =
551552 MappingField { mappingFieldName :: FieldName
552− , fieldDefinition :: FieldDefinition } deriving (Eq, Show, Generic, Typeable)
553+ , fieldDefinition :: FieldDefinition } deriving (Eq, Read, Show, Generic, Typeable)
553554
554555{-| Support for type reification of 'Mapping's is currently incomplete, for
555556 now the mapping API verbiage expects a 'ToJSON'able blob.
@@ -559,7 +560,7 @@ data MappingField =
559560 and keeping different kinds of documents separated if possible.
560561-}
561562data Mapping = Mapping { typeName :: TypeName
562− , mappingFields :: [MappingField] } deriving (Eq, Show, Generic, Typeable)
563+ , mappingFields :: [MappingField] } deriving (Eq, Read, Show, Generic, Typeable)
563564
564565{-| 'BulkOperation' is a sum type for expressing the four kinds of bulk
565566 operation index, create, delete, and update. 'BulkIndex' behaves like an
@@ -571,7 +572,7 @@ data BulkOperation =
571572 BulkIndex IndexName MappingName DocId Value
572573 | BulkCreate IndexName MappingName DocId Value
573574 | BulkDelete IndexName MappingName DocId
574− | BulkUpdate IndexName MappingName DocId Value deriving (Eq, Show, Generic, Typeable)
575+ | BulkUpdate IndexName MappingName DocId Value deriving (Eq, Read, Show, Generic, Typeable)
575576
576577{-| 'EsResult' describes the standard wrapper JSON document that you see in
577578 successful Elasticsearch lookups or lookups that couldn't find the document.
@@ -579,20 +580,20 @@ data BulkOperation =
579580data EsResult a = EsResult { _index :: Text
580581 , _type :: Text
581582 , _id :: Text
582− , foundResult :: Maybe (EsResultFound a)} deriving (Eq, Show, Generic, Typeable)
583+ , foundResult :: Maybe (EsResultFound a)} deriving (Eq, Read, Show, Generic, Typeable)
583584
584585{-| 'EsResultFound' contains the document and its metadata inside of an
585586 'EsResult' when the document was successfully found.
586587-}
587588data EsResultFound a = EsResultFound { _version :: DocVersion
588− , _source :: a } deriving (Eq, Show, Generic, Typeable)
589+ , _source :: a } deriving (Eq, Read, Show, Generic, Typeable)
589590
590591{-| 'EsError' is the generic type that will be returned when there was a
591592 problem. If you can't parse the expected response, its a good idea to
592593 try parsing this.
593594-}
594595data EsError = EsError { errorStatus :: Int
595− , errorMessage :: Text } deriving (Eq, Show, Generic, Typeable)
596+ , errorMessage :: Text } deriving (Eq, Read, Show, Generic, Typeable)
596597
597598{-| 'EsProtocolException' will be thrown if Bloodhound cannot parse a response
598599returned by the ElasticSearch server. If you encounter this error, please
@@ -603,44 +604,44 @@ incompatibility between Bloodhound and ElasticSearch. Please open a bug report
603604and be sure to include the exception body.
604605-}
605606data EsProtocolException = EsProtocolException { esProtoExBody :: L.ByteString }
606− deriving (Eq, Show, Generic, Typeable)
607+ deriving (Eq, Read, Show, Generic, Typeable)
607608
608609instance Exception EsProtocolException
609610
610611data IndexAlias = IndexAlias { srcIndex :: IndexName
611− , indexAlias :: IndexAliasName } deriving (Eq, Show, Generic, Typeable)
612+ , indexAlias :: IndexAliasName } deriving (Eq, Read, Show, Generic, Typeable)
612613
613−newtype IndexAliasName = IndexAliasName { indexAliasName :: IndexName } deriving (Eq, Show, Generic, ToJSON)
614+newtype IndexAliasName = IndexAliasName { indexAliasName :: IndexName } deriving (Eq, Read, Show, Generic, ToJSON)
614615
615616data IndexAliasAction = AddAlias IndexAlias IndexAliasCreate
616− | RemoveAlias IndexAlias deriving (Show, Eq, Generic, Typeable)
617+ | RemoveAlias IndexAlias deriving (Read, Show, Eq, Generic, Typeable)
617618
618619data IndexAliasCreate = IndexAliasCreate { aliasCreateRouting :: Maybe AliasRouting
619620 , aliasCreateFilter :: Maybe Filter}
620− deriving (Show, Eq, Generic, Typeable)
621+ deriving (Read, Show, Eq, Generic, Typeable)
621622
622623data AliasRouting = AllAliasRouting RoutingValue
623624 | GranularAliasRouting (Maybe SearchAliasRouting) (Maybe IndexAliasRouting)
624− deriving (Show, Eq, Generic, Typeable)
625+ deriving (Read, Show, Eq, Generic, Typeable)
625626
626−newtype SearchAliasRouting = SearchAliasRouting (NonEmpty RoutingValue) deriving (Show, Eq, Generic, Typeable)
627+newtype SearchAliasRouting = SearchAliasRouting (NonEmpty RoutingValue) deriving (Read, Show, Eq, Generic, Typeable)
627628
628−newtype IndexAliasRouting = IndexAliasRouting RoutingValue deriving (Show, Eq, Generic, ToJSON, FromJSON, Typeable)
629+newtype IndexAliasRouting = IndexAliasRouting RoutingValue deriving (Read, Show, Eq, Generic, ToJSON, FromJSON, Typeable)
629630
630−newtype RoutingValue = RoutingValue { routingValue :: Text } deriving (Show, Eq, Generic, ToJSON, FromJSON, Typeable)
631+newtype RoutingValue = RoutingValue { routingValue :: Text } deriving (Read, Show, Eq, Generic, ToJSON, FromJSON, Typeable)
631632
632−newtype IndexAliasesSummary = IndexAliasesSummary { indexAliasesSummary :: [IndexAliasSummary] } deriving (Show, Eq, Generic, Typeable)
633+newtype IndexAliasesSummary = IndexAliasesSummary { indexAliasesSummary :: [IndexAliasSummary] } deriving (Read, Show, Eq, Generic, Typeable)
633634
634635{-| 'IndexAliasSummary' is a summary of an index alias configured for a server. -}
635636data IndexAliasSummary = IndexAliasSummary { indexAliasSummaryAlias :: IndexAlias
636− , indexAliasSummaryCreate :: IndexAliasCreate} deriving (Show, Eq, Generic, Typeable)
637+ , indexAliasSummaryCreate :: IndexAliasCreate} deriving (Read, Show, Eq, Generic, Typeable)
637638
638639{-| 'DocVersion' is an integer version number for a document between 1
639640and 9.2e+18 used for <<https://www.elastic.co/guide/en/elasticsearch/guide/current/optimistic-concurrency-control.html optimistic concurrency control>>.
640641-}
641642newtype DocVersion = DocVersion {
642643 docVersionNumber :: Int
643− } deriving (Eq, Show, Generic, Ord, ToJSON)
644+ } deriving (Eq, Read, Show, Generic, Ord, ToJSON)
644645
645646-- | Smart constructor for in-range doc version
646647mkDocVersion :: Int -> Maybe DocVersion
@@ -654,7 +655,7 @@ mkDocVersion i
654655own version numbers instead of ones from ES.
655656-}
656657newtype ExternalDocVersion = ExternalDocVersion DocVersion
657− deriving (Eq, Show, Generic, Ord, Bounded, Enum, ToJSON)
658+ deriving (Eq, Read, Show, Generic, Ord, Bounded, Enum, ToJSON)
658659
659660{-| 'VersionControl' is specified when indexing documents as a
660661optimistic concurrency control.
@@ -688,12 +689,12 @@ data VersionControl = NoVersionControl
688689 -- given version will be the new version. This is
689690 -- typically used for correcting errors. Use with
690691 -- care, as this could result in data loss.
691− deriving (Show, Eq, Generic, Ord)
692+ deriving (Read, Show, Eq, Generic, Ord)
692693
693694{-| 'DocumentParent' is used to specify a parent document.
694695-}
695696newtype DocumentParent = DocumentParent DocId
696− deriving (Eq, Show, Generic, Typeable)
697+ deriving (Eq, Read, Show, Generic, Typeable)
697698
698699{-| 'IndexDocumentSettings' are special settings supplied when indexing
699700a document. For the best backwards compatiblity when new fields are
@@ -702,7 +703,7 @@ added, you should probably prefer to start with 'defaultIndexDocumentSettings'
702703data IndexDocumentSettings =
703704 IndexDocumentSettings { idsVersionControl :: VersionControl
704705 , idsParent :: Maybe DocumentParent
705− } deriving (Eq, Show, Generic, Typeable)
706+ } deriving (Eq, Read, Show, Generic, Typeable)
706707
707708{-| Reasonable default settings. Chooses no version control and no parent.
708709-}
@@ -722,7 +723,7 @@ type Sort = [SortSpec]
722723<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#search-request-sort>
723724-}
724725data SortSpec = DefaultSortSpec DefaultSort
725− | GeoDistanceSortSpec SortOrder GeoPoint DistanceUnit deriving (Eq, Show, Generic, Typeable)
726+ | GeoDistanceSortSpec SortOrder GeoPoint DistanceUnit deriving (Eq, Read, Show, Generic, Typeable)
726727
727728{-| 'DefaultSort' is usually the kind of 'SortSpec' you'll want. There's a
728729 'mkSort' convenience function for when you want to specify only the most
@@ -737,7 +738,7 @@ data DefaultSort =
737738 , ignoreUnmapped :: Bool
738739 , sortMode :: Maybe SortMode
739740 , missingSort :: Maybe Missing
740− , nestedFilter :: Maybe Filter } deriving (Eq, Show, Generic, Typeable)
741+ , nestedFilter :: Maybe Filter } deriving (Eq, Read, Show, Generic, Typeable)
741742
742743{-| 'SortOrder' is 'Ascending' or 'Descending', as you might expect. These get
743744 encoded into "asc" or "desc" when turned into JSON.
@@ -745,7 +746,7 @@ data DefaultSort =
745746<http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-sort.html#search-request-sort>
746747-}
747748data SortOrder = Ascending
748− | Descending deriving (Eq, Show, Generic, Typeable)
749+ | Descending deriving (Eq, Read, Show, Generic, Typeable)
749750
750751{-| 'Missing' prescribes how to handle missing fields. A missing field can be
751752 sorted last, first, or using a custom value as a substitute.
@@ -754,7 +755,7 @@ data SortOrder = Ascending
754755-}
755756data Missing = LastMissing
756757 | FirstMissing
757− | CustomMissing Text deriving (Eq, Show, Generic, Typeable)
758+ | CustomMissing Text deriving (Eq, Read, Show, Generic, Typeable)
758759
759760{-| 'SortMode' prescribes how to handle sorting array/multi-valued fields.
760761
@@ -763,7 +764,7 @@ http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-req
763764data SortMode = SortMin
764765 | SortMax
765766 | SortSum
766− | SortAvg deriving (Eq, Show, Generic, Typeable)
767+ | SortAvg deriving (Eq, Read, Show, Generic, Typeable)
767768
768769{-| 'mkSort' defaults everything but the 'FieldName' and the 'SortOrder' so
769770 that you can concisely describe the usual kind of 'SortSpec's you want.
@@ -785,19 +786,19 @@ type PrefixValue = Text
785786{-| 'BooleanOperator' is the usual And/Or operators with an ES compatible
786787 JSON encoding baked in. Used all over the place.
787788-}
788−data BooleanOperator = And | Or deriving (Eq, Show, Generic, Typeable)
789+data BooleanOperator = And | Or deriving (Eq, Read, Show, Generic, Typeable)
789790
790791{-| 'ShardCount' is part of 'IndexSettings'
791792-}
792−newtype ShardCount = ShardCount Int deriving (Eq, Show, Generic, ToJSON, Typeable)
793+newtype ShardCount = ShardCount Int deriving (Eq, Read, Show, Generic, ToJSON, Typeable)
793794
794795{-| 'ReplicaCount' is part of 'IndexSettings'
795796-}
796−newtype ReplicaCount = ReplicaCount Int deriving (Eq, Show, Generic, ToJSON, Typeable)
797+newtype ReplicaCount = ReplicaCount Int deriving (Eq, Read, Show, Generic, ToJSON, Typeable)
797798
798799{-| 'IndexName' is used to describe which index to query/create/delete
799800-}
800−newtype IndexName = IndexName Text deriving (Eq, Generic, Show, ToJSON, FromJSON, Typeable)
801+newtype IndexName = IndexName Text deriving (Eq, Generic, Read, Show, ToJSON, FromJSON, Typeable)
801802
802803{-| 'IndexSelection' is used for APIs which take a single index, a list of
803804 indexes, or the special @_all@ index.
@@ -807,133 +808,133 @@ data IndexSelection = IndexList (NonEmpty IndexName)
807808
808809{-| 'TemplateName' is used to describe which template to query/create/delete
809810-}
810−newtype TemplateName = TemplateName Text deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
811+newtype TemplateName = TemplateName Text deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
811812
812813{-| 'TemplatePattern' represents a pattern which is matched against index names
813814-}
814−newtype TemplatePattern = TemplatePattern Text deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
815+newtype TemplatePattern = TemplatePattern Text deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
815816
816817{-| 'MappingName' is part of mappings which are how ES describes and schematizes
817818 the data in the indices.
818819-}
819−newtype MappingName = MappingName Text deriving (Eq, Generic, Show, ToJSON, FromJSON, Typeable)
820+newtype MappingName = MappingName Text deriving (Eq, Generic, Read, Show, ToJSON, FromJSON, Typeable)
820821
821822{-| 'DocId' is a generic wrapper value for expressing unique Document IDs.
822823 Can be set by the user or created by ES itself. Often used in client
823824 functions for poking at specific documents.
824825-}
825−newtype DocId = DocId Text deriving (Eq, Generic, Show, ToJSON, FromJSON, Typeable)
826+newtype DocId = DocId Text deriving (Eq, Generic, Read, Show, ToJSON, FromJSON, Typeable)
826827
827828{-| 'QueryString' is used to wrap query text bodies, be they human written or not.
828829-}
829−newtype QueryString = QueryString Text deriving (Eq, Generic, Show, ToJSON, FromJSON, Typeable)
830+newtype QueryString = QueryString Text deriving (Eq, Generic, Read, Show, ToJSON, FromJSON, Typeable)
830831
831832{-| 'FieldName' is used all over the place wherever a specific field within
832833 a document needs to be specified, usually in 'Query's or 'Filter's.
833834-}
834−newtype FieldName = FieldName Text deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
835+newtype FieldName = FieldName Text deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
835836
836837
837838{-| 'Script' is often used in place of 'FieldName' to specify more
838839complex ways of extracting a value from a document.
839840-}
840−newtype Script = Script { scriptText :: Text } deriving (Eq, Show, Generic, Typeable)
841+newtype Script = Script { scriptText :: Text } deriving (Eq, Read, Show, Generic, Typeable)
841842
842843{-| 'CacheName' is used in 'RegexpFilter' for describing the
843844 'CacheKey' keyed caching behavior.
844845-}
845−newtype CacheName = CacheName Text deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
846+newtype CacheName = CacheName Text deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
846847
847848{-| 'CacheKey' is used in 'RegexpFilter' to key regex caching.
848849-}
849850newtype CacheKey =
850− CacheKey Text deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
851+ CacheKey Text deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
851852newtype Existence =
852− Existence Bool deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
853+ Existence Bool deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
853854newtype NullValue =
854− NullValue Bool deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
855+ NullValue Bool deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
855856newtype CutoffFrequency =
856− CutoffFrequency Double deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
857+ CutoffFrequency Double deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
857858newtype Analyzer =
858− Analyzer Text deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
859+ Analyzer Text deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
859860newtype MaxExpansions =
860− MaxExpansions Int deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
861+ MaxExpansions Int deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
861862
862863{-| 'Lenient', if set to true, will cause format based failures to be
863864 ignored. I don't know what the bloody default is, Elasticsearch
864865 documentation didn't say what it was. Let me know if you figure it out.
865866-}
866867newtype Lenient =
867− Lenient Bool deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
868+ Lenient Bool deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
868869newtype Tiebreaker =
869− Tiebreaker Double deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
870+ Tiebreaker Double deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
870871newtype Boost =
871− Boost Double deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
872+ Boost Double deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
872873newtype BoostTerms =
873− BoostTerms Double deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
874+ BoostTerms Double deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
874875
875876{-| 'MinimumMatch' controls how many should clauses in the bool query should
876877 match. Can be an absolute value (2) or a percentage (30%) or a
877878 combination of both.
878879-}
879880newtype MinimumMatch =
880− MinimumMatch Int deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
881+ MinimumMatch Int deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
881882newtype DisableCoord =
882− DisableCoord Bool deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
883+ DisableCoord Bool deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
883884newtype IgnoreTermFrequency =
884− IgnoreTermFrequency Bool deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
885+ IgnoreTermFrequency Bool deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
885886newtype MinimumTermFrequency =
886− MinimumTermFrequency Int deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
887+ MinimumTermFrequency Int deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
887888newtype MaxQueryTerms =
888− MaxQueryTerms Int deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
889+ MaxQueryTerms Int deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
889890newtype Fuzziness =
890− Fuzziness Double deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
891+ Fuzziness Double deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
891892
892893{-| 'PrefixLength' is the prefix length used in queries, defaults to 0. -}
893894newtype PrefixLength =
894− PrefixLength Int deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
895+ PrefixLength Int deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
895896newtype TypeName =
896− TypeName Text deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
897+ TypeName Text deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
897898newtype PercentMatch =
898− PercentMatch Double deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
899+ PercentMatch Double deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
899900newtype StopWord =
900− StopWord Text deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
901+ StopWord Text deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
901902newtype QueryPath =
902− QueryPath Text deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
903+ QueryPath Text deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
903904
904905{-| Allowing a wildcard at the beginning of a word (eg "*ing") is particularly
905906 heavy, because all terms in the index need to be examined, just in case
906907 they match. Leading wildcards can be disabled by setting
907908 'AllowLeadingWildcard' to false. -}
908909newtype AllowLeadingWildcard =
909− AllowLeadingWildcard Bool deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
910+ AllowLeadingWildcard Bool deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
910911newtype LowercaseExpanded =
911− LowercaseExpanded Bool deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
912+ LowercaseExpanded Bool deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
912913newtype EnablePositionIncrements =
913− EnablePositionIncrements Bool deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
914+ EnablePositionIncrements Bool deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
914915
915916{-| By default, wildcard terms in a query are not analyzed.
916917 Setting 'AnalyzeWildcard' to true enables best-effort analysis.
917918-}
918−newtype AnalyzeWildcard = AnalyzeWildcard Bool deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
919+newtype AnalyzeWildcard = AnalyzeWildcard Bool deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
919920
920921{-| 'GeneratePhraseQueries' defaults to false.
921922-}
922923newtype GeneratePhraseQueries =
923− GeneratePhraseQueries Bool deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
924+ GeneratePhraseQueries Bool deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
924925
925926{-| 'Locale' is used for string conversions - defaults to ROOT.
926927-}
927−newtype Locale = Locale Text deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
928−newtype MaxWordLength = MaxWordLength Int deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
929−newtype MinWordLength = MinWordLength Int deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
928+newtype Locale = Locale Text deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
929+newtype MaxWordLength = MaxWordLength Int deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
930+newtype MinWordLength = MinWordLength Int deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
930931
931932{-| 'PhraseSlop' sets the default slop for phrases, 0 means exact
932933 phrase matches. Default is 0.
933934-}
934−newtype PhraseSlop = PhraseSlop Int deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
935−newtype MinDocFrequency = MinDocFrequency Int deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
936−newtype MaxDocFrequency = MaxDocFrequency Int deriving (Eq, Show, Generic, ToJSON, FromJSON, Typeable)
935+newtype PhraseSlop = PhraseSlop Int deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
936+newtype MinDocFrequency = MinDocFrequency Int deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
937+newtype MaxDocFrequency = MaxDocFrequency Int deriving (Eq, Read, Show, Generic, ToJSON, FromJSON, Typeable)
937938
938939-- | Newtype wrapper to parse ES's concerning tendency to in some APIs return a floating point number of milliseconds since epoch ಠ_ಠ
939940newtype POSIXMS = POSIXMS { posixMS :: UTCTime }
@@ -944,8 +945,8 @@ unpackId :: DocId -> Text
944945unpackId (DocId docId) = docId
945946
946947type TrackSortScores = Bool
947−newtype From = From Int deriving (Eq, Show, Generic, ToJSON)
948−newtype Size = Size Int deriving (Eq, Show, Generic, ToJSON)
948+newtype From = From Int deriving (Eq, Read, Show, Generic, ToJSON)
949+newtype Size = Size Int deriving (Eq, Read, Show, Generic, ToJSON)
949950
950951data Search = Search { queryBody :: Maybe Query
951952 , filterBody :: Maybe Filter
@@ -958,7 +959,7 @@ data Search = Search { queryBody :: Maybe Query
958959 , size :: Size
959960 , searchType :: SearchType
960961 , fields :: Maybe [FieldName]
961− , source :: Maybe Source } deriving (Eq, Show, Generic, Typeable)
962+ , source :: Maybe Source } deriving (Eq, Read, Show, Generic, Typeable)
962963
963964data SearchType = SearchTypeQueryThenFetch
964965 | SearchTypeDfsQueryThenFetch
@@ -966,40 +967,40 @@ data SearchType = SearchTypeQueryThenFetch
966967 | SearchTypeScan
967968 | SearchTypeQueryAndFetch
968969 | SearchTypeDfsQueryAndFetch
969− deriving (Eq, Show, Generic, Typeable)
970+ deriving (Eq, Read, Show, Generic, Typeable)
970971
971972data Source =
972973 NoSource
973974 | SourcePatterns PatternOrPatterns
974975 | SourceIncludeExclude Include Exclude
975− deriving (Show, Eq, Generic, Typeable)
976+ deriving (Read, Show, Eq, Generic, Typeable)
976977
977978data PatternOrPatterns = PopPattern Pattern
978− | PopPatterns [Pattern] deriving (Eq, Show, Generic, Typeable)
979+ | PopPatterns [Pattern] deriving (Eq, Read, Show, Generic, Typeable)
979980
980−data Include = Include [Pattern] deriving (Eq, Show, Generic, Typeable)
981−data Exclude = Exclude [Pattern] deriving (Eq, Show, Generic, Typeable)
981+data Include = Include [Pattern] deriving (Eq, Read, Show, Generic, Typeable)
982+data Exclude = Exclude [Pattern] deriving (Eq, Read, Show, Generic, Typeable)
982983
983−newtype Pattern = Pattern Text deriving (Eq, Show, Generic, Typeable)
984+newtype Pattern = Pattern Text deriving (Eq, Read, Show, Generic, Typeable)
984985
985986data Highlights = Highlights { globalsettings :: Maybe HighlightSettings
986987 , highlightFields :: [FieldHighlight]
987− } deriving (Show, Eq, Generic, Typeable)
988+ } deriving (Read, Show, Eq, Generic, Typeable)
988989
989990data FieldHighlight = FieldHighlight FieldName (Maybe HighlightSettings)
990− deriving (Show, Eq, Generic, Typeable)
991+ deriving (Read, Show, Eq, Generic, Typeable)
991992
992993
993994data HighlightSettings = Plain PlainHighlight
994995 | Postings PostingsHighlight
995996 | FastVector FastVectorHighlight
996− deriving (Show, Eq, Generic, Typeable)
997+ deriving (Read, Show, Eq, Generic, Typeable)
997998data PlainHighlight =
998999 PlainHighlight { plainCommon :: Maybe CommonHighlight
999− , plainNonPost :: Maybe NonPostings } deriving (Show, Eq, Generic, Typeable)
1000+ , plainNonPost :: Maybe NonPostings } deriving (Read, Show, Eq, Generic, Typeable)
10001001
10011002 -- This requires that index_options are set to 'offset' in the mapping.
1002−data PostingsHighlight = PostingsHighlight (Maybe CommonHighlight) deriving (Show, Eq, Generic, Typeable)
1003+data PostingsHighlight = PostingsHighlight (Maybe CommonHighlight) deriving (Read, Show, Eq, Generic, Typeable)
10031004
10041005-- This requires that term_vector is set to 'with_positions_offsets' in the mapping.
10051006data FastVectorHighlight =
@@ -1010,7 +1011,7 @@ data FastVectorHighlight =
10101011 , fragmentOffset :: Maybe Int
10111012 , matchedFields :: [Text]
10121013 , phraseLimit :: Maybe Int
1013− } deriving (Show, Eq, Generic, Typeable)
1014+ } deriving (Read, Show, Eq, Generic, Typeable)
10141015
10151016data CommonHighlight =
10161017 CommonHighlight { order :: Maybe Text
@@ -1020,21 +1021,21 @@ data CommonHighlight =
10201021 , noMatchSize :: Maybe Int
10211022 , highlightQuery :: Maybe Query
10221023 , requireFieldMatch :: Maybe Bool
1023− } deriving (Show, Eq, Generic, Typeable)
1024+ } deriving (Read, Show, Eq, Generic, Typeable)
10241025
10251026-- Settings that are only applicable to FastVector and Plain highlighters.
10261027data NonPostings =
10271028 NonPostings { fragmentSize :: Maybe Int
1028− , numberOfFragments :: Maybe Int} deriving (Show, Eq, Generic, Typeable)
1029+ , numberOfFragments :: Maybe Int} deriving (Read, Show, Eq, Generic, Typeable)
10291030
10301031data HighlightEncoder = DefaultEncoder
10311032 | HTMLEncoder
1032− deriving (Show, Eq, Generic, Typeable)
1033+ deriving (Read, Show, Eq, Generic, Typeable)
10331034
10341035-- NOTE: Should the tags use some kind of HTML type, rather than Text?
10351036data HighlightTag = TagSchema Text
10361037 | CustomTags ([Text], [Text]) -- Only uses more than the first value in the lists if fvh
1037− deriving (Show, Eq, Generic, Typeable)
1038+ deriving (Read, Show, Eq, Generic, Typeable)
10381039
10391040
10401041data Query =
@@ -1065,19 +1066,19 @@ data Query =
10651066 | QuerySimpleQueryStringQuery SimpleQueryStringQuery
10661067 | QueryRangeQuery RangeQuery
10671068 | QueryRegexpQuery RegexpQuery
1068− deriving (Eq, Show, Generic, Typeable)
1069+ deriving (Eq, Read, Show, Generic, Typeable)
10691070
10701071data RegexpQuery =
10711072 RegexpQuery { regexpQueryField :: FieldName
10721073 , regexpQuery :: Regexp
10731074 , regexpQueryFlags :: RegexpFlags
10741075 , regexpQueryBoost :: Maybe Boost
1075− } deriving (Eq, Show, Generic, Typeable)
1076+ } deriving (Eq, Read, Show, Generic, Typeable)
10761077
10771078data RangeQuery =
10781079 RangeQuery { rangeQueryField :: FieldName
10791080 , rangeQueryRange :: RangeValue
1080− , rangeQueryBoost :: Boost } deriving (Eq, Show, Generic, Typeable)
1081+ , rangeQueryBoost :: Boost } deriving (Eq, Read, Show, Generic, Typeable)
10811082
10821083mkRangeQuery :: FieldName -> RangeValue -> RangeQuery
10831084mkRangeQuery f r = RangeQuery f r (Boost 1.0)
@@ -1091,7 +1092,7 @@ data SimpleQueryStringQuery =
10911092 , simpleQueryStringFlags :: Maybe (NonEmpty SimpleQueryFlag)
10921093 , simpleQueryStringLowercaseExpanded :: Maybe LowercaseExpanded
10931094 , simpleQueryStringLocale :: Maybe Locale
1094− } deriving (Eq, Show, Generic, Typeable)
1095+ } deriving (Eq, Read, Show, Generic, Typeable)
10951096
10961097data SimpleQueryFlag =
10971098 SimpleQueryAll
@@ -1105,7 +1106,7 @@ data SimpleQueryFlag =
11051106 | SimpleQueryWhitespace
11061107 | SimpleQueryFuzzy
11071108 | SimpleQueryNear
1108− | SimpleQuerySlop deriving (Eq, Show, Generic, Typeable)
1109+ | SimpleQuerySlop deriving (Eq, Read, Show, Generic, Typeable)
11091110
11101111-- use_dis_max and tie_breaker when fields are plural?
11111112data QueryStringQuery =
@@ -1127,7 +1128,7 @@ data QueryStringQuery =
11271128 , queryStringMinimumShouldMatch :: Maybe MinimumMatch
11281129 , queryStringLenient :: Maybe Lenient
11291130 , queryStringLocale :: Maybe Locale
1130− } deriving (Eq, Show, Generic, Typeable)
1131+ } deriving (Eq, Read, Show, Generic, Typeable)
11311132
11321133mkQueryStringQuery :: QueryString -> QueryStringQuery
11331134mkQueryStringQuery qs =
@@ -1138,19 +1139,19 @@ mkQueryStringQuery qs =
11381139 Nothing Nothing
11391140
11401141data FieldOrFields = FofField FieldName
1141− | FofFields (NonEmpty FieldName) deriving (Eq, Show, Generic, Typeable)
1142+ | FofFields (NonEmpty FieldName) deriving (Eq, Read, Show, Generic, Typeable)
11421143
11431144data PrefixQuery =
11441145 PrefixQuery
11451146 { prefixQueryField :: FieldName
11461147 , prefixQueryPrefixValue :: Text
1147− , prefixQueryBoost :: Maybe Boost } deriving (Eq, Show, Generic, Typeable)
1148+ , prefixQueryBoost :: Maybe Boost } deriving (Eq, Read, Show, Generic, Typeable)
11481149
11491150data NestedQuery =
11501151 NestedQuery
11511152 { nestedQueryPath :: QueryPath
11521153 , nestedQueryScoreType :: ScoreType
1153− , nestedQuery :: Query } deriving (Eq, Show, Generic, Typeable)
1154+ , nestedQuery :: Query } deriving (Eq, Read, Show, Generic, Typeable)
11541155
11551156data MoreLikeThisFieldQuery =
11561157 MoreLikeThisFieldQuery
@@ -1168,7 +1169,7 @@ data MoreLikeThisFieldQuery =
11681169 , moreLikeThisFieldBoostTerms :: Maybe BoostTerms
11691170 , moreLikeThisFieldBoost :: Maybe Boost
11701171 , moreLikeThisFieldAnalyzer :: Maybe Analyzer
1171− } deriving (Eq, Show, Generic, Typeable)
1172+ } deriving (Eq, Read, Show, Generic, Typeable)
11721173
11731174data MoreLikeThisQuery =
11741175 MoreLikeThisQuery
@@ -1186,32 +1187,32 @@ data MoreLikeThisQuery =
11861187 , moreLikeThisBoostTerms :: Maybe BoostTerms
11871188 , moreLikeThisBoost :: Maybe Boost
11881189 , moreLikeThisAnalyzer :: Maybe Analyzer
1189− } deriving (Eq, Show, Generic, Typeable)
1190+ } deriving (Eq, Read, Show, Generic, Typeable)
11901191
11911192data IndicesQuery =
11921193 IndicesQuery
11931194 { indicesQueryIndices :: [IndexName]
11941195 , indicesQuery :: Query
11951196 -- default "all"
1196− , indicesQueryNoMatch :: Maybe Query } deriving (Eq, Show, Generic, Typeable)
1197+ , indicesQueryNoMatch :: Maybe Query } deriving (Eq, Read, Show, Generic, Typeable)
11971198
11981199data HasParentQuery =
11991200 HasParentQuery
12001201 { hasParentQueryType :: TypeName
12011202 , hasParentQuery :: Query
1202− , hasParentQueryScoreType :: Maybe ScoreType } deriving (Eq, Show, Generic, Typeable)
1203+ , hasParentQueryScoreType :: Maybe ScoreType } deriving (Eq, Read, Show, Generic, Typeable)
12031204
12041205data HasChildQuery =
12051206 HasChildQuery
12061207 { hasChildQueryType :: TypeName
12071208 , hasChildQuery :: Query
1208− , hasChildQueryScoreType :: Maybe ScoreType } deriving (Eq, Show, Generic, Typeable)
1209+ , hasChildQueryScoreType :: Maybe ScoreType } deriving (Eq, Read, Show, Generic, Typeable)
12091210
12101211data ScoreType =
12111212 ScoreTypeMax
12121213 | ScoreTypeSum
12131214 | ScoreTypeAvg
1214− | ScoreTypeNone deriving (Eq, Show, Generic, Typeable)
1215+ | ScoreTypeNone deriving (Eq, Read, Show, Generic, Typeable)
12151216
12161217data FuzzyQuery =
12171218 FuzzyQuery { fuzzyQueryField :: FieldName
@@ -1220,7 +1221,7 @@ data FuzzyQuery =
12201221 , fuzzyQueryMaxExpansions :: MaxExpansions
12211222 , fuzzyQueryFuzziness :: Fuzziness
12221223 , fuzzyQueryBoost :: Maybe Boost
1223− } deriving (Eq, Show, Generic, Typeable)
1224+ } deriving (Eq, Read, Show, Generic, Typeable)
12241225
12251226data FuzzyLikeFieldQuery =
12261227 FuzzyLikeFieldQuery
@@ -1233,7 +1234,7 @@ data FuzzyLikeFieldQuery =
12331234 , fuzzyLikeFieldPrefixLength :: PrefixLength
12341235 , fuzzyLikeFieldBoost :: Boost
12351236 , fuzzyLikeFieldAnalyzer :: Maybe Analyzer
1236− } deriving (Eq, Show, Generic, Typeable)
1237+ } deriving (Eq, Read, Show, Generic, Typeable)
12371238
12381239data FuzzyLikeThisQuery =
12391240 FuzzyLikeThisQuery
@@ -1245,19 +1246,19 @@ data FuzzyLikeThisQuery =
12451246 , fuzzyLikePrefixLength :: PrefixLength
12461247 , fuzzyLikeBoost :: Boost
12471248 , fuzzyLikeAnalyzer :: Maybe Analyzer
1248− } deriving (Eq, Show, Generic, Typeable)
1249+ } deriving (Eq, Read, Show, Generic, Typeable)
12491250
12501251data FilteredQuery =
12511252 FilteredQuery
12521253 { filteredQuery :: Query
1253− , filteredFilter :: Filter } deriving (Eq, Show, Generic, Typeable)
1254+ , filteredFilter :: Filter } deriving (Eq, Read, Show, Generic, Typeable)
12541255
12551256data DisMaxQuery =
12561257 DisMaxQuery { disMaxQueries :: [Query]
12571258 -- default 0.0
12581259 , disMaxTiebreaker :: Tiebreaker
12591260 , disMaxBoost :: Maybe Boost
1260− } deriving (Eq, Show, Generic, Typeable)
1261+ } deriving (Eq, Read, Show, Generic, Typeable)
12611262
12621263data MatchQuery =
12631264 MatchQuery { matchQueryField :: FieldName
@@ -1269,7 +1270,7 @@ data MatchQuery =
12691270 , matchQueryAnalyzer :: Maybe Analyzer
12701271 , matchQueryMaxExpansions :: Maybe MaxExpansions
12711272 , matchQueryLenient :: Maybe Lenient
1272− , matchQueryBoost :: Maybe Boost } deriving (Eq, Show, Generic, Typeable)
1273+ , matchQueryBoost :: Maybe Boost } deriving (Eq, Read, Show, Generic, Typeable)
12731274
12741275{-| 'mkMatchQuery' is a convenience function that defaults the less common parameters,
12751276 enabling you to provide only the 'FieldName' and 'QueryString' to make a 'MatchQuery'
@@ -1279,7 +1280,7 @@ mkMatchQuery field query = MatchQuery field query Or ZeroTermsNone Nothing Nothi
12791280
12801281data MatchQueryType =
12811282 MatchPhrase
1282− | MatchPhrasePrefix deriving (Eq, Show, Generic, Typeable)
1283+ | MatchPhrasePrefix deriving (Eq, Read, Show, Generic, Typeable)
12831284
12841285data MultiMatchQuery =
12851286 MultiMatchQuery { multiMatchQueryFields :: [FieldName]
@@ -1291,7 +1292,7 @@ data MultiMatchQuery =
12911292 , multiMatchQueryCutoffFrequency :: Maybe CutoffFrequency
12921293 , multiMatchQueryAnalyzer :: Maybe Analyzer
12931294 , multiMatchQueryMaxExpansions :: Maybe MaxExpansions
1294− , multiMatchQueryLenient :: Maybe Lenient } deriving (Eq, Show, Generic, Typeable)
1295+ , multiMatchQueryLenient :: Maybe Lenient } deriving (Eq, Read, Show, Generic, Typeable)
12951296
12961297{-| 'mkMultiMatchQuery' is a convenience function that defaults the less common parameters,
12971298 enabling you to provide only the list of 'FieldName's and 'QueryString' to
@@ -1308,7 +1309,7 @@ data MultiMatchQueryType =
13081309 | MultiMatchMostFields
13091310 | MultiMatchCrossFields
13101311 | MultiMatchPhrase
1311− | MultiMatchPhrasePrefix deriving (Eq, Show, Generic, Typeable)
1312+ | MultiMatchPhrasePrefix deriving (Eq, Read, Show, Generic, Typeable)
13121313
13131314data BoolQuery =
13141315 BoolQuery { boolQueryMustMatch :: [Query]
@@ -1317,7 +1318,7 @@ data BoolQuery =
13171318 , boolQueryMinimumShouldMatch :: Maybe MinimumMatch
13181319 , boolQueryBoost :: Maybe Boost
13191320 , boolQueryDisableCoord :: Maybe DisableCoord
1320− } deriving (Eq, Show, Generic, Typeable)
1321+ } deriving (Eq, Read, Show, Generic, Typeable)
13211322
13221323mkBoolQuery :: [Query] -> [Query] -> [Query] -> BoolQuery
13231324mkBoolQuery must mustNot should =
@@ -1326,7 +1327,7 @@ mkBoolQuery must mustNot should =
13261327data BoostingQuery =
13271328 BoostingQuery { positiveQuery :: Query
13281329 , negativeQuery :: Query
1329− , negativeBoost :: Boost } deriving (Eq, Show, Generic, Typeable)
1330+ , negativeBoost :: Boost } deriving (Eq, Read, Show, Generic, Typeable)
13301331
13311332data CommonTermsQuery =
13321333 CommonTermsQuery { commonField :: FieldName
@@ -1338,16 +1339,16 @@ data CommonTermsQuery =
13381339 , commonBoost :: Maybe Boost
13391340 , commonAnalyzer :: Maybe Analyzer
13401341 , commonDisableCoord :: Maybe DisableCoord
1341− } deriving (Eq, Show, Generic, Typeable)
1342+ } deriving (Eq, Read, Show, Generic, Typeable)
13421343
13431344data CommonMinimumMatch =
13441345 CommonMinimumMatchHighLow MinimumMatchHighLow
13451346 | CommonMinimumMatch MinimumMatch
1346− deriving (Eq, Show, Generic, Typeable)
1347+ deriving (Eq, Read, Show, Generic, Typeable)
13471348
13481349data MinimumMatchHighLow =
13491350 MinimumMatchHighLow { lowFreq :: MinimumMatch
1350− , highFreq :: MinimumMatch } deriving (Eq, Show, Generic, Typeable)
1351+ , highFreq :: MinimumMatch } deriving (Eq, Read, Show, Generic, Typeable)
13511352
13521353data Filter = AndFilter [Filter] Cache
13531354 | OrFilter [Filter] Cache
@@ -1367,36 +1368,36 @@ data Filter = AndFilter [Filter] Cache
13671368 | RangeFilter FieldName RangeValue RangeExecution Cache
13681369 | RegexpFilter FieldName Regexp RegexpFlags CacheName Cache CacheKey
13691370 | TermFilter Term Cache
1370− deriving (Eq, Show, Generic, Typeable)
1371+ deriving (Eq, Read, Show, Generic, Typeable)
13711372
13721373data ZeroTermsQuery = ZeroTermsNone
1373− | ZeroTermsAll deriving (Eq, Show, Generic, Typeable)
1374+ | ZeroTermsAll deriving (Eq, Read, Show, Generic, Typeable)
13741375
13751376data RangeExecution = RangeExecutionIndex
1376− | RangeExecutionFielddata deriving (Eq, Show, Generic, Typeable)
1377+ | RangeExecutionFielddata deriving (Eq, Read, Show, Generic, Typeable)
13771378
1378−newtype Regexp = Regexp Text deriving (Eq, Show, Generic, Typeable, FromJSON)
1379+newtype Regexp = Regexp Text deriving (Eq, Read, Show, Generic, Typeable, FromJSON)
13791380
13801381data RegexpFlags = AllRegexpFlags
13811382 | NoRegexpFlags
1382− | SomeRegexpFlags (NonEmpty RegexpFlag) deriving (Eq, Show, Generic, Typeable)
1383+ | SomeRegexpFlags (NonEmpty RegexpFlag) deriving (Eq, Read, Show, Generic, Typeable)
13831384
13841385data RegexpFlag = AnyString
13851386 | Automaton
13861387 | Complement
13871388 | Empty
13881389 | Intersection
1389− | Interval deriving (Eq, Show, Generic, Typeable)
1390+ | Interval deriving (Eq, Read, Show, Generic, Typeable)
13901391
1391−newtype LessThan = LessThan Double deriving (Eq, Show, Generic, Typeable)
1392−newtype LessThanEq = LessThanEq Double deriving (Eq, Show, Generic, Typeable)
1393−newtype GreaterThan = GreaterThan Double deriving (Eq, Show, Generic, Typeable)
1394−newtype GreaterThanEq = GreaterThanEq Double deriving (Eq, Show, Generic, Typeable)
1392+newtype LessThan = LessThan Double deriving (Eq, Read, Show, Generic, Typeable)
1393+newtype LessThanEq = LessThanEq Double deriving (Eq, Read, Show, Generic, Typeable)
1394+newtype GreaterThan = GreaterThan Double deriving (Eq, Read, Show, Generic, Typeable)
1395+newtype GreaterThanEq = GreaterThanEq Double deriving (Eq, Read, Show, Generic, Typeable)
13951396
1396−newtype LessThanD = LessThanD UTCTime deriving (Eq, Show, Generic, Typeable)
1397−newtype LessThanEqD = LessThanEqD UTCTime deriving (Eq, Show, Generic, Typeable)
1398−newtype GreaterThanD = GreaterThanD UTCTime deriving (Eq, Show, Generic, Typeable)
1399−newtype GreaterThanEqD = GreaterThanEqD UTCTime deriving (Eq, Show, Generic, Typeable)
1397+newtype LessThanD = LessThanD UTCTime deriving (Eq, Read, Show, Generic, Typeable)
1398+newtype LessThanEqD = LessThanEqD UTCTime deriving (Eq, Read, Show, Generic, Typeable)
1399+newtype GreaterThanD = GreaterThanD UTCTime deriving (Eq, Read, Show, Generic, Typeable)
1400+newtype GreaterThanEqD = GreaterThanEqD UTCTime deriving (Eq, Read, Show, Generic, Typeable)
14001401
14011402data RangeValue = RangeDateLte LessThanEqD
14021403 | RangeDateLt LessThanD
@@ -1414,7 +1415,7 @@ data RangeValue = RangeDateLte LessThanEqD
14141415 | RangeDoubleGteLte GreaterThanEq LessThanEq
14151416 | RangeDoubleGteLt GreaterThanEq LessThan
14161417 | RangeDoubleGtLte GreaterThan LessThanEq
1417− deriving (Eq, Show, Generic, Typeable)
1418+ deriving (Eq, Read, Show, Generic, Typeable)
14181419
14191420rangeValueToPair :: RangeValue -> [Pair]
14201421rangeValueToPair rv = case rv of
@@ -1436,33 +1437,33 @@ rangeValueToPair rv = case rv of
14361437 RangeDoubleGtLt (GreaterThan l) (LessThan g) -> ["gt" .= l, "lt" .= g]
14371438
14381439data Term = Term { termField :: Text
1439− , termValue :: Text } deriving (Eq, Show, Generic, Typeable)
1440+ , termValue :: Text } deriving (Eq, Read, Show, Generic, Typeable)
14401441
14411442data BoolMatch = MustMatch Term Cache
14421443 | MustNotMatch Term Cache
1443− | ShouldMatch [Term] Cache deriving (Eq, Show, Generic, Typeable)
1444+ | ShouldMatch [Term] Cache deriving (Eq, Read, Show, Generic, Typeable)
14441445
14451446-- "memory" or "indexed"
14461447data GeoFilterType = GeoFilterMemory
1447− | GeoFilterIndexed deriving (Eq, Show, Generic, Typeable)
1448+ | GeoFilterIndexed deriving (Eq, Read, Show, Generic, Typeable)
14481449
14491450data LatLon = LatLon { lat :: Double
1450− , lon :: Double } deriving (Eq, Show, Generic, Typeable)
1451+ , lon :: Double } deriving (Eq, Read, Show, Generic, Typeable)
14511452
14521453data GeoBoundingBox =
14531454 GeoBoundingBox { topLeft :: LatLon
1454− , bottomRight :: LatLon } deriving (Eq, Show, Generic, Typeable)
1455+ , bottomRight :: LatLon } deriving (Eq, Read, Show, Generic, Typeable)
14551456
14561457data GeoBoundingBoxConstraint =
14571458 GeoBoundingBoxConstraint { geoBBField :: FieldName
14581459 , constraintBox :: GeoBoundingBox
14591460 , bbConstraintcache :: Cache
14601461 , geoType :: GeoFilterType
1461− } deriving (Eq, Show, Generic, Typeable)
1462+ } deriving (Eq, Read, Show, Generic, Typeable)
14621463
14631464data GeoPoint =
14641465 GeoPoint { geoField :: FieldName
1465− , latLon :: LatLon} deriving (Eq, Show, Generic, Typeable)
1466+ , latLon :: LatLon} deriving (Eq, Read, Show, Generic, Typeable)
14661467
14671468data DistanceUnit = Miles
14681469 | Yards
@@ -1472,22 +1473,22 @@ data DistanceUnit = Miles
14721473 | Meters
14731474 | Centimeters
14741475 | Millimeters
1475− | NauticalMiles deriving (Eq, Show, Generic, Typeable)
1476+ | NauticalMiles deriving (Eq, Read, Show, Generic, Typeable)
14761477
14771478data DistanceType = Arc
14781479 | SloppyArc -- doesn't exist <1.0
1479− | Plane deriving (Eq, Show, Generic, Typeable)
1480+ | Plane deriving (Eq, Read, Show, Generic, Typeable)
14801481
14811482data OptimizeBbox = OptimizeGeoFilterType GeoFilterType
1482− | NoOptimizeBbox deriving (Eq, Show, Generic, Typeable)
1483+ | NoOptimizeBbox deriving (Eq, Read, Show, Generic, Typeable)
14831484
14841485data Distance =
14851486 Distance { coefficient :: Double
1486− , unit :: DistanceUnit } deriving (Eq, Show, Generic, Typeable)
1487+ , unit :: DistanceUnit } deriving (Eq, Read, Show, Generic, Typeable)
14871488
14881489data DistanceRange =
14891490 DistanceRange { distanceFrom :: Distance
1490− , distanceTo :: Distance } deriving (Eq, Show, Generic, Typeable)
1491+ , distanceTo :: Distance } deriving (Eq, Read, Show, Generic, Typeable)
14911492
14921493data SearchResult a =
14931494 SearchResult { took :: Int
@@ -1495,16 +1496,16 @@ data SearchResult a =
14951496 , shards :: ShardResult
14961497 , searchHits :: SearchHits a
14971498 , aggregations :: Maybe AggregationResults
1498− , scrollId :: Maybe ScrollId } deriving (Eq, Show, Generic, Typeable)
1499+ , scrollId :: Maybe ScrollId } deriving (Eq, Read, Show, Generic, Typeable)
14991500
1500−newtype ScrollId = ScrollId Text deriving (Eq, Show, Generic, Ord, ToJSON, FromJSON)
1501+newtype ScrollId = ScrollId Text deriving (Eq, Read, Show, Generic, Ord, ToJSON, FromJSON)
15011502
15021503type Score = Maybe Double
15031504
15041505data SearchHits a =
15051506 SearchHits { hitsTotal :: Int
15061507 , maxScore :: Score
1507− , hits :: [Hit a] } deriving (Eq, Show, Generic, Typeable)
1508+ , hits :: [Hit a] } deriving (Eq, Read, Show, Generic, Typeable)
15081509
15091510
15101511instance Monoid (SearchHits a) where
@@ -1519,12 +1520,12 @@ data Hit a =
15191520 , hitDocId :: DocId
15201521 , hitScore :: Score
15211522 , hitSource :: Maybe a
1522− , hitHighlight :: Maybe HitHighlight } deriving (Eq, Show, Generic, Typeable)
1523+ , hitHighlight :: Maybe HitHighlight } deriving (Eq, Read, Show, Generic, Typeable)
15231524
15241525data ShardResult =
15251526 ShardResult { shardTotal :: Int
15261527 , shardsSuccessful :: Int
1527− , shardsFailed :: Int } deriving (Eq, Show, Generic, Typeable)
1528+ , shardsFailed :: Int } deriving (Eq, Read, Show, Generic, Typeable)
15281529
15291530type HitHighlight = M.Map Text [Text]
15301531
@@ -1548,25 +1549,25 @@ mkAggregations :: Text -> Aggregation -> Aggregations
15481549mkAggregations name aggregation = M.insert name aggregation emptyAggregations
15491550
15501551data TermOrder = TermOrder{ termSortField :: Text
1551− , termSortOrder :: SortOrder } deriving (Eq, Show, Generic, Typeable)
1552+ , termSortOrder :: SortOrder } deriving (Eq, Read, Show, Generic, Typeable)
15521553
15531554data TermInclusion = TermInclusion Text
1554− | TermPattern Text Text deriving (Eq, Show, Generic, Typeable)
1555+ | TermPattern Text Text deriving (Eq, Read, Show, Generic, Typeable)
15551556
15561557data CollectionMode = BreadthFirst
1557− | DepthFirst deriving (Eq, Show, Generic, Typeable)
1558+ | DepthFirst deriving (Eq, Read, Show, Generic, Typeable)
15581559
15591560data ExecutionHint = Ordinals
15601561 | GlobalOrdinals
15611562 | GlobalOrdinalsHash
15621563 | GlobalOrdinalsLowCardinality
1563− | Map deriving (Eq, Show, Generic, Typeable)
1564+ | Map deriving (Eq, Read, Show, Generic, Typeable)
15641565
15651566data TimeInterval = Weeks
15661567 | Days
15671568 | Hours
15681569 | Minutes
1569− | Seconds deriving (Eq)
1570+ | Seconds deriving Eq
15701571
15711572data Interval = Year
15721573 | Quarter
@@ -1576,18 +1577,18 @@ data Interval = Year
15761577 | Hour
15771578 | Minute
15781579 | Second
1579− | FractionalInterval Float TimeInterval deriving (Eq, Show, Generic, Typeable)
1580+ | FractionalInterval Float TimeInterval deriving (Eq, Read, Show, Generic, Typeable)
15801581
15811582data Aggregation = TermsAgg TermsAggregation
15821583 | DateHistogramAgg DateHistogramAggregation
15831584 | ValueCountAgg ValueCountAggregation
15841585 | FilterAgg FilterAggregation
15851586 | DateRangeAgg DateRangeAggregation
1586− | MissingAgg MissingAggregation deriving (Eq, Show, Generic, Typeable)
1587+ | MissingAgg MissingAggregation deriving (Eq, Read, Show, Generic, Typeable)
15871588
15881589data MissingAggregation = MissingAggregation
15891590 { maField :: Text
1590− } deriving (Eq, Show, Generic, Typeable)
1591+ } deriving (Eq, Read, Show, Generic, Typeable)
15911592
15921593data TermsAggregation = TermsAggregation { term :: Either Text Text
15931594 , termInclude :: Maybe TermInclusion
@@ -1599,7 +1600,7 @@ data TermsAggregation = TermsAggregation { term :: Either Text Text
15991600 , termCollectMode :: Maybe CollectionMode
16001601 , termExecutionHint :: Maybe ExecutionHint
16011602 , termAggs :: Maybe Aggregations
1602− } deriving (Eq, Show, Generic, Typeable)
1603+ } deriving (Eq, Read, Show, Generic, Typeable)
16031604
16041605data DateHistogramAggregation = DateHistogramAggregation { dateField :: FieldName
16051606 , dateInterval :: Interval
@@ -1610,29 +1611,29 @@ data DateHistogramAggregation = DateHistogramAggregation { dateField :: Fie
16101611 , datePreOffset :: Maybe Text
16111612 , datePostOffset :: Maybe Text
16121613 , dateAggs :: Maybe Aggregations
1613− } deriving (Eq, Show, Generic, Typeable)
1614+ } deriving (Eq, Read, Show, Generic, Typeable)
16141615
16151616
16161617data DateRangeAggregation = DateRangeAggregation { draField :: FieldName
16171618 , draFormat :: Maybe Text
16181619 , draRanges :: NonEmpty DateRangeAggRange
1619− } deriving (Eq, Show, Generic, Typeable)
1620+ } deriving (Eq, Read, Show, Generic, Typeable)
16201621
16211622data DateRangeAggRange = DateRangeFrom DateMathExpr
16221623 | DateRangeTo DateMathExpr
1623− | DateRangeFromAndTo DateMathExpr DateMathExpr deriving (Eq, Show, Generic, Typeable)
1624+ | DateRangeFromAndTo DateMathExpr DateMathExpr deriving (Eq, Read, Show, Generic, Typeable)
16241625
16251626-- | See <https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math> for more information.
1626−data DateMathExpr = DateMathExpr DateMathAnchor [DateMathModifier] deriving (Eq, Show, Generic, Typeable)
1627+data DateMathExpr = DateMathExpr DateMathAnchor [DateMathModifier] deriving (Eq, Read, Show, Generic, Typeable)
16271628
16281629
16291630-- | Starting point for a date range. This along with the 'DateMathModifiers' gets you the date ES will start from.
16301631data DateMathAnchor = DMNow
1631− | DMDate Day deriving (Eq, Show, Generic, Typeable)
1632+ | DMDate Day deriving (Eq, Read, Show, Generic, Typeable)
16321633
16331634data DateMathModifier = AddTime Int DateMathUnit
16341635 | SubtractTime Int DateMathUnit
1635− | RoundDownTo DateMathUnit deriving (Eq, Show, Generic, Typeable)
1636+ | RoundDownTo DateMathUnit deriving (Eq, Read, Show, Generic, Typeable)
16361637
16371638data DateMathUnit = DMYear
16381639 | DMMonth
@@ -1640,15 +1641,15 @@ data DateMathUnit = DMYear
16401641 | DMDay
16411642 | DMHour
16421643 | DMMinute
1643− | DMSecond deriving (Eq, Show, Generic, Typeable)
1644+ | DMSecond deriving (Eq, Read, Show, Generic, Typeable)
16441645
16451646-- | See <https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-valuecount-aggregation.html> for more information.
16461647data ValueCountAggregation = FieldValueCount FieldName
1647− | ScriptValueCount Script deriving (Eq, Show, Generic, Typeable)
1648+ | ScriptValueCount Script deriving (Eq, Read, Show, Generic, Typeable)
16481649
16491650-- | 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.
16501651data FilterAggregation = FilterAggregation { faFilter :: Filter
1651− , faAggs :: Maybe Aggregations} deriving (Eq, Show, Generic, Typeable)
1652+ , faAggs :: Maybe Aggregations} deriving (Eq, Read, Show, Generic, Typeable)
16521653
16531654mkTermsAggregation :: Text -> TermsAggregation
16541655mkTermsAggregation t = TermsAggregation (Left t) Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing Nothing
@@ -1712,6 +1713,16 @@ instance Show TimeInterval where
17121713 show Minutes = "m"
17131714 show Seconds = "s"
17141715
1716+instance Read TimeInterval where
1717+ readPrec = f =<< TR.get
1718+ where
1719+ f 'w' = return Weeks
1720+ f 'd' = return Days
1721+ f 'h' = return Hours
1722+ f 'm' = return Minutes
1723+ f 's' = return Seconds
1724+ f _ = fail "TimeInterval expected one of w, d, h, m, s"
1725+
17151726instance ToJSON Aggregation where
17161727 toJSON (TermsAgg (TermsAggregation term include exclude order minDocCount size shardSize collectMode executionHint termAggs)) =
17171728 omitNulls ["terms" .= omitNulls [ toJSON' term,
@@ -1789,22 +1800,22 @@ class BucketAggregation a where
17891800 aggs :: a -> Maybe AggregationResults
17901801
17911802
1792−data Bucket a = Bucket { buckets :: [a]} deriving (Show)
1803+data Bucket a = Bucket { buckets :: [a]} deriving (Read, Show)
17931804
17941805data BucketValue = TextValue Text
17951806 | ScientificValue Scientific
1796− | BoolValue Bool deriving (Show)
1807+ | BoolValue Bool deriving (Read, Show)
17971808
17981809data MissingResult = MissingResult { missingDocCount :: Int } deriving (Show)
17991810
18001811data TermsResult = TermsResult { termKey :: BucketValue
18011812 , termsDocCount :: Int
1802− , termsAggs :: Maybe AggregationResults } deriving (Show)
1813+ , termsAggs :: Maybe AggregationResults } deriving (Read, Show)
18031814
18041815data DateHistogramResult = DateHistogramResult { dateKey :: Int
18051816 , dateKeyStr :: Maybe Text
18061817 , dateDocCount :: Int
1807− , dateHistogramAggs :: Maybe AggregationResults } deriving (Show)
1818+ , dateHistogramAggs :: Maybe AggregationResults } deriving (Read, Show)
18081819
18091820data DateRangeResult = DateRangeResult { dateRangeKey :: Text
18101821 , dateRangeFrom :: Maybe UTCTime
@@ -1812,7 +1823,7 @@ data DateRangeResult = DateRangeResult { dateRangeKey :: Text
18121823 , dateRangeTo :: Maybe UTCTime
18131824 , dateRangeToAsString :: Maybe Text
18141825 , dateRangeDocCount :: Int
1815− , dateRangeAggs :: Maybe AggregationResults } deriving (Show, Eq, Generic, Typeable)
1826+ , dateRangeAggs :: Maybe AggregationResults } deriving (Read, Show, Eq, Generic, Typeable)
18161827
18171828toTerms :: Text -> AggregationResults -> Maybe (Bucket TermsResult)
18181829toTerms = toAggResult
@@ -3610,7 +3621,7 @@ instance Enum DocVersion where
36103621 enumFromThen = boundedEnumFromThen
36113622
36123623-- | Username type used for HTTP Basic authentication. See 'basicAuthHook'.
3613−newtype EsUsername = EsUsername { esUsername :: Text } deriving (Show, Eq)
3624+newtype EsUsername = EsUsername { esUsername :: Text } deriving (Read, Show, Eq)
36143625
36153626-- | Password type used for HTTP Basic authentication. See 'basicAuthHook'.
3616−newtype EsPassword = EsPassword { esPassword :: Text } deriving (Show, Eq)
3627+newtype EsPassword = EsPassword { esPassword :: Text } deriving (Read, Show, Eq)