Skip to content

Commit

Permalink
Switch to Haskell filters
Browse files Browse the repository at this point in the history
  • Loading branch information
dzhus committed Jan 12, 2016
1 parent e54c565 commit d4a12d1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions es-reindex.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ executable es-reindex
, http-client
, http-types
, mtl
, text
, time
, turtle
, vector
11 changes: 5 additions & 6 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Network.HTTP.Types
import Turtle.Options

import qualified Data.ByteString.Lazy as B
import qualified Data.Text.Lazy as LT
import qualified Data.Vector as V

data Options = Options
Expand Down Expand Up @@ -56,14 +57,12 @@ main = do
manager <- newManager defaultManagerSettings
filtStr <- case filter_ opts of
Nothing -> return Nothing
Just Stdin -> Just . fromString . ltextToString <$> getContents
Just (File p) -> Just . encodeUtf8 <$> readFile (textToString p)
let mkBH s = BHEnv (fromMaybe (Server "http://127.0.0.1:9200") s) manager
Just Stdin -> Just . LT.toStrict <$> getContents
Just (File p) -> Just <$> readFile (textToString p)
let mkBH s = mkBHEnv (fromMaybe (Server "http://127.0.0.1:9200") s) manager
sourceBH = mkBH $ sourceServer opts
destBH = mkBH $ destinationServer opts
filt = case decodeStrict' <$> filtStr of
Just Nothing -> error "Failed to parse filter JSON"
x -> join x
filt = read <$> filtStr
searchLength@(Size lengthN) = fromMaybe (Size 100) (frameLength opts)
search = def { size = searchLength, filterBody = filt }
bulkSize' = fromMaybe 78643200 $ bulkSize opts
Expand Down
6 changes: 5 additions & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ packages:
git: https://github.com/bos/aeson
commit: 4de5a203eeeea593457bc92bc40062f3ea830426 # master
extra-dep: true
- location:
git: https://github.com/MailOnline/bloodhound
commit: 0265202ff3a94b2384880a9ee02fbd38708e557a
extra-dep: true
extra-deps:
- aeson-0.10.0.0
- attoparsec-0.13.0.1
- bloodhound-0.10.0.0
- bloodhound-0.10.0.1
- data-default-generics-0.3
resolver: lts-3.18

0 comments on commit d4a12d1

Please sign in to comment.