git.iko.soy/typeable/bloodhound
on master help sign in
add ability to change compression codec. This allows us to use DEFLATE instead of lz4.

document what compression will actually be used

commit142e864fb16d86695652d146992e42e1c5df856b authorAndrew Martin <andrew.thaddeus@gmail.com> dateTue 5 Dec 2017, 13:31 (9 years ago) parent07f6bc5
1 file changed+25
src/Database/V5/Bloodhound/Types.hs+25
src/Database/V5/Bloodhound/Types.hs+25
@@ -74,6 +74,7 @@ module Database.V5.Bloodhound.Types
7474 , UpdatableIndexSetting(..)
7575 , IndexSettingsSummary(..)
7676 , AllocationPolicy(..)
77+ , Compression(..)
7778 , ReplicaBounds(..)
7879 , Bytes(..)
7980 , gigabytes
@@ -586,6 +587,7 @@ data UpdatableIndexSetting = NumberOfReplicas ReplicaCount
586587 | TTLDisablePurge Bool
587588 -- ^ Disables temporarily the purge of expired docs.
588589 | TranslogFSType FSType
590+ | CompressionSetting Compression
589591 | IndexCompoundFormat CompoundFormat
590592 | IndexCompoundOnFlush Bool
591593 | WarmerEnabled Bool
@@ -688,6 +690,26 @@ data ReplicaBounds = ReplicasBounded Int Int
688690 | ReplicasUnbounded
689691 deriving (Eq, Read, Show, Generic, Typeable)
690692
693+data Compression
694+ = CompressionDefault
695+ -- ^ Compress with LZ4
696+ | CompressionBest
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)
701+
702+instance ToJSON Compression where
703+ toJSON x = case x of
704+ CompressionDefault -> toJSON ("default" :: Text)
705+ CompressionBest -> toJSON ("best_compression" :: Text)
706+
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"
712+
691713-- | A measure of bytes used for various configurations. You may want
692714-- to use smart constructors like 'gigabytes' for larger values.
693715--
@@ -3079,6 +3101,7 @@ instance ToJSON UpdatableIndexSetting where
30793101 toJSON (GCDeletes x) = oPath ("index" :| ["gc_deletes"]) (NominalDiffTimeJSON x)
30803102 toJSON (TTLDisablePurge x) = oPath ("index" :| ["ttl", "disable_purge"]) x
30813103 toJSON (TranslogFSType x) = oPath ("index" :| ["translog", "fs", "type"]) x
3104+ toJSON (CompressionSetting x) = oPath ("index" :| ["codec"]) x
30823105 toJSON (IndexCompoundFormat x) = oPath ("index" :| ["compound_format"]) x
30833106 toJSON (IndexCompoundOnFlush x) = oPath ("index" :| ["compound_on_flush"]) x
30843107 toJSON (WarmerEnabled x) = oPath ("index" :| ["warmer", "enabled"]) x
@@ -3112,6 +3135,7 @@ instance FromJSON UpdatableIndexSetting where
31123135 <|> gcDeletes `taggedAt` ["index", "gc_deletes"]
31133136 <|> ttlDisablePurge `taggedAt` ["index", "ttl", "disable_purge"]
31143137 <|> translogFSType `taggedAt` ["index", "translog", "fs", "type"]
3138+ <|> compressionSetting `taggedAt` ["index", "codec"]
31153139 <|> compoundFormat `taggedAt` ["index", "compound_format"]
31163140 <|> compoundOnFlush `taggedAt` ["index", "compound_on_flush"]
31173141 <|> warmerEnabled `taggedAt` ["index", "warmer", "enabled"]
@@ -3146,6 +3170,7 @@ instance FromJSON UpdatableIndexSetting where
31463170 gcDeletes = pure . GCDeletes . ndtJSON
31473171 ttlDisablePurge = pure . TTLDisablePurge
31483172 translogFSType = pure . TranslogFSType
3173+ compressionSetting = pure . CompressionSetting
31493174 compoundFormat = pure . IndexCompoundFormat
31503175 compoundOnFlush = pure . IndexCompoundOnFlush
31513176 warmerEnabled = pure . WarmerEnabled