1{-# LANGUAGE OverloadedStrings #-}
3module Test.BulkAPI (spec) where
8import qualified Data.Vector as V
9import qualified Lens.Micro.Aeson as LMA
15instance ToJSON BulkTest where
16 toJSON (BulkTest name') =
17 object ["name" .= name']
19instance FromJSON BulkTest where
20 parseJSON = withObject "BulkTest" parse
24 BulkTest <$> parseJSON t
29 it "inserts all documents we request" $ withTestEnv $ do
31 let firstTest = BulkTest "blah"
32 let secondTest = BulkTest "bloo"
33 let firstDoc = BulkIndex testIndex
34 testMapping (DocId "2") (toJSON firstTest)
35 let secondDoc = BulkCreate testIndex
36 testMapping (DocId "3") (toJSON secondTest)
37 let stream = V.fromList [firstDoc, secondDoc]
39 _ <- refreshIndex testIndex
40 fDoc <- getDocument testIndex testMapping (DocId "2")
41 sDoc <- getDocument testIndex testMapping (DocId "3")
42 -- note that we cannot query for fourthDoc and fifthDoc since we
43 -- do not know their autogenerated ids.
47 :: Either String (EsResult BulkTest)
51 :: Either String (EsResult BulkTest)
53 fmap getSource maybeFirst `shouldBe` Right (Just firstTest)
54 fmap getSource maybeSecond `shouldBe` Right (Just secondTest)
55 -- Since we can't get the docs by doc id, we check for their existence in
57 let query = MatchAllQuery Nothing
58 let search = mkSearch (Just query) Nothing
59 resp <- searchByIndex testIndex search
60 parsed <- parseEsResponse resp :: BH IO (Either EsError (SearchResult Value))
63 liftIO $ expectationFailure ("Expected a script-transformed result but got: " <> show e)
66 hitsTotal (searchHits sr) `shouldBe` 3
67 let nameList :: [Text]
77 `shouldBe` ["blah","bloo"]
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list