on master help sign in
Fix: generalize index mapping function
fb5280dAleksey Uimanov
katip-elasticsearch/src/Katip/Scribes/ElasticSearch/Internal.hs+6−4
@@ -268,10 +268,13 @@ mkEsScribe
268 -> IndexName v
268 -> IndexName v
269 -- ^ Treated as a prefix if index sharding is enabled
269 -- ^ Treated as a prefix if index sharding is enabled
270 -> MappingName v
270 -> MappingName v
271+ -> Value
272+ -- ^ Index mapping value. Use 'baseMapping' as default value
273+ -- constructor.
271 -> PermitFunc
274 -> PermitFunc
272 -> Verbosity
275 -> Verbosity
273 -> IO Scribe
276 -> IO Scribe
274−mkEsScribe cfg@EsScribeCfg {..} env ix mapping permit verb = do
277+mkEsScribe cfg@EsScribeCfg {..} env ix mapping mappingValue permit verb = do
275 q <- newTBMQueueIO $ unEsQueueSize essQueueSize
278 q <- newTBMQueueIO $ unEsQueueSize essQueueSize
276 endSig <- newEmptyMVar
279 endSig <- newEmptyMVar
277
280
@@ -293,7 +296,7 @@ mkEsScribe cfg@EsScribeCfg {..} env ix mapping permit verb = do
293 r1 <- createIndex prx essIndexSettings ix
296 r1 <- createIndex prx essIndexSettings ix
294 unless (statusIsSuccessful (responseStatus r1)) $
297 unless (statusIsSuccessful (responseStatus r1)) $
295 liftIO $ EX.throwIO (CouldNotCreateIndex r1)
298 liftIO $ EX.throwIO (CouldNotCreateIndex r1)
296− r2 <- putMapping prx ix mapping base
299+ r2 <- putMapping prx ix mapping mappingValue
297 unless (statusIsSuccessful (responseStatus r2)) $
300 unless (statusIsSuccessful (responseStatus r2)) $
298 liftIO $ EX.throwIO (CouldNotCreateMapping r2)
301 liftIO $ EX.throwIO (CouldNotCreateMapping r2)
299
302
@@ -318,8 +321,7 @@ mkEsScribe cfg@EsScribeCfg {..} env ix mapping permit verb = do
318 shardingEnabled = case essIndexSharding of
321 shardingEnabled = case essIndexSharding of
319 NoIndexSharding -> False
322 NoIndexSharding -> False
320 _ -> True
323 _ -> True
321− tpl = toIndexTemplate prx (toTemplatePattern prx (ixn <> "-*")) (Just essIndexSettings) [toJSON base]
324+ tpl = toIndexTemplate prx (toTemplatePattern prx (ixn <> "-*")) (Just essIndexSettings) [mappingValue]
322− base = baseMapping prx mapping
323 ixn = fromIndexName prx ix
325 ixn = fromIndexName prx ix
324 itemJson' :: LogItem a => Item a -> Value
326 itemJson' :: LogItem a => Item a -> Value
325 itemJson' i
327 itemJson' i
katip-elasticsearch/test/Main.hs+3−1
@@ -161,7 +161,9 @@ setupSearch
161setupSearch prx modScribeCfg = do
161setupSearch prx modScribeCfg = do
162 bh prx (dropESSchema prx)
162 bh prx (dropESSchema prx)
163 mgr <- newManager defaultManagerSettings
163 mgr <- newManager defaultManagerSettings
164+ let mname = mn prx
164− mkEsScribe cfg (mkBHEnv prx (svr prx) mgr) (ixn prx) (mn prx) (permitItem DebugS) V3
165+ mkEsScribe cfg (mkBHEnv prx (svr prx) mgr) (ixn prx) mname (baseMapping prx mname)
166+ (permitItem DebugS) V3
165 where
167 where
166 cfg :: EsScribeCfg v
168 cfg :: EsScribeCfg v
167 cfg = modScribeCfg $
169 cfg = modScribeCfg $