@@ -215,6 +215,7 @@ dispatch dMethod url body = do
215215 $ setRequestIgnoreStatus
216216 $ initReq { method = dMethod
217217 , requestHeaders =
218+ -- "application/x-ndjson" for bulk
218219 ("Content-Type", "application/json") : requestHeaders initReq
219220 , requestBody = reqBody }
220221 -- req <- liftIO $ reqHook $ setRequestIgnoreStatus $ initReq { method = dMethod
@@ -856,7 +857,9 @@ deleteDocument (IndexName indexName)
856857-- >>> _ <- runBH' $ bulk stream
857858-- >>> _ <- runBH' $ refreshIndex testIndex
858859bulk :: MonadBH m => V.Vector BulkOperation -> m Reply
859−bulk bulkOps = bindM2 post url (return body)
860+bulk bulkOps = do
861+ liftIO $ print body
862+ bindM2 post url (return body)
860863 where url = joinPath ["_bulk"]
861864 body = Just $ encodeBulkOperations bulkOps
862865
@@ -868,9 +871,12 @@ bulk bulkOps = bindM2 post url (return body)
868871-- "\n{\"index\":{\"_type\":\"tweet\",\"_id\":\"2\",\"_index\":\"twitter\"}}\n{\"name\":\"blah\"}\n"
869872encodeBulkOperations :: V.Vector BulkOperation -> L.ByteString
870873encodeBulkOperations stream = collapsed where
871− blobs = fmap encodeBulkOperation stream
872− mashedTaters = mash (mempty :: Builder) blobs
873− collapsed = toLazyByteString $ mappend mashedTaters (byteString "\n")
874+ blobs =
875+ fmap encodeBulkOperation stream
876+ mashedTaters =
877+ mash (mempty :: Builder) blobs
878+ collapsed =
879+ toLazyByteString $ mappend mashedTaters (byteString "\n")
874880
875881mash :: Builder -> V.Vector L.ByteString -> Builder
876882mash = V.foldl' (\b x -> b `mappend` (byteString "\n") `mappend` (lazyByteString x))