@@ -74,6 +74,7 @@ module Database.V5.Bloodhound.Types
74 , UpdatableIndexSetting(..)
74 , UpdatableIndexSetting(..)
75 , IndexSettingsSummary(..)
75 , IndexSettingsSummary(..)
76 , AllocationPolicy(..)
76 , AllocationPolicy(..)
77 , ReplicaBounds(..)
78 , ReplicaBounds(..)
78 , Bytes(..)
79 , Bytes(..)
79 , gigabytes
80 , gigabytes
@@ -586,6 +587,7 @@ data UpdatableIndexSetting = NumberOfReplicas ReplicaCount
586 | TTLDisablePurge Bool
587 | TTLDisablePurge Bool
587 -- ^ Disables temporarily the purge of expired docs.
588 -- ^ Disables temporarily the purge of expired docs.
588 | TranslogFSType FSType
589 | TranslogFSType FSType
590+ | CompressionSetting Compression
589 | IndexCompoundFormat CompoundFormat
591 | IndexCompoundFormat CompoundFormat
590 | IndexCompoundOnFlush Bool
592 | IndexCompoundOnFlush Bool
591 | WarmerEnabled Bool
593 | WarmerEnabled Bool
@@ -688,6 +690,26 @@ data ReplicaBounds = ReplicasBounded Int Int
688 | ReplicasUnbounded
690 | ReplicasUnbounded
689 deriving (Eq, Read, Show, Generic, Typeable)
691 deriving (Eq, Read, Show, Generic, Typeable)
694+ = CompressionDefault
695+ -- ^ Compress with LZ4
697+ -- ^ Compress with DEFLATE. Elastic
698+ -- <https://www.elastic.co/blog/elasticsearch-storage-the-true-story-2.0 blogs>
699+ -- that this can reduce disk use by 15%-25%.
700+ deriving (Eq,Show,Generic,Typeable)
702+instance ToJSON Compression where
703+ toJSON x = case x of
704+ CompressionDefault -> toJSON ("default" :: Text)
705+ CompressionBest -> toJSON ("best_compression" :: Text)
707+instance FromJSON Compression where
708+ parseJSON = withText "Compression" $ \t -> case t of
709+ "default" -> return CompressionDefault
710+ "best_compression" -> return CompressionBest
711+ _ -> fail "invalid compression codec"
691-- | A measure of bytes used for various configurations. You may want
713-- | A measure of bytes used for various configurations. You may want
692-- to use smart constructors like 'gigabytes' for larger values.
714-- to use smart constructors like 'gigabytes' for larger values.
@@ -3079,6 +3101,7 @@ instance ToJSON UpdatableIndexSetting where
3079 toJSON (GCDeletes x) = oPath ("index" :| ["gc_deletes"]) (NominalDiffTimeJSON x)
3101 toJSON (GCDeletes x) = oPath ("index" :| ["gc_deletes"]) (NominalDiffTimeJSON x)
3080 toJSON (TTLDisablePurge x) = oPath ("index" :| ["ttl", "disable_purge"]) x
3102 toJSON (TTLDisablePurge x) = oPath ("index" :| ["ttl", "disable_purge"]) x
3081 toJSON (TranslogFSType x) = oPath ("index" :| ["translog", "fs", "type"]) x
3103 toJSON (TranslogFSType x) = oPath ("index" :| ["translog", "fs", "type"]) x
3104+ toJSON (CompressionSetting x) = oPath ("index" :| ["codec"]) x
3082 toJSON (IndexCompoundFormat x) = oPath ("index" :| ["compound_format"]) x
3105 toJSON (IndexCompoundFormat x) = oPath ("index" :| ["compound_format"]) x
3083 toJSON (IndexCompoundOnFlush x) = oPath ("index" :| ["compound_on_flush"]) x
3106 toJSON (IndexCompoundOnFlush x) = oPath ("index" :| ["compound_on_flush"]) x
3084 toJSON (WarmerEnabled x) = oPath ("index" :| ["warmer", "enabled"]) x
3107 toJSON (WarmerEnabled x) = oPath ("index" :| ["warmer", "enabled"]) x
@@ -3112,6 +3135,7 @@ instance FromJSON UpdatableIndexSetting where
3112 <|> gcDeletes `taggedAt` ["index", "gc_deletes"]
3135 <|> gcDeletes `taggedAt` ["index", "gc_deletes"]
3113 <|> ttlDisablePurge `taggedAt` ["index", "ttl", "disable_purge"]
3136 <|> ttlDisablePurge `taggedAt` ["index", "ttl", "disable_purge"]
3114 <|> translogFSType `taggedAt` ["index", "translog", "fs", "type"]
3137 <|> translogFSType `taggedAt` ["index", "translog", "fs", "type"]
3138+ <|> compressionSetting `taggedAt` ["index", "codec"]
3115 <|> compoundFormat `taggedAt` ["index", "compound_format"]
3139 <|> compoundFormat `taggedAt` ["index", "compound_format"]
3116 <|> compoundOnFlush `taggedAt` ["index", "compound_on_flush"]
3140 <|> compoundOnFlush `taggedAt` ["index", "compound_on_flush"]
3117 <|> warmerEnabled `taggedAt` ["index", "warmer", "enabled"]
3141 <|> warmerEnabled `taggedAt` ["index", "warmer", "enabled"]
@@ -3146,6 +3170,7 @@ instance FromJSON UpdatableIndexSetting where
3146 gcDeletes = pure . GCDeletes . ndtJSON
3170 gcDeletes = pure . GCDeletes . ndtJSON
3147 ttlDisablePurge = pure . TTLDisablePurge
3171 ttlDisablePurge = pure . TTLDisablePurge
3148 translogFSType = pure . TranslogFSType
3172 translogFSType = pure . TranslogFSType
3173+ compressionSetting = pure . CompressionSetting
3149 compoundFormat = pure . IndexCompoundFormat
3174 compoundFormat = pure . IndexCompoundFormat
3150 compoundOnFlush = pure . IndexCompoundOnFlush
3175 compoundOnFlush = pure . IndexCompoundOnFlush
3151 warmerEnabled = pure . WarmerEnabled
3176 warmerEnabled = pure . WarmerEnabled