Commit 95e8f01a authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] need a start

parent a8799bb2
......@@ -36,7 +36,7 @@ imt = [
main :: IO ()
main = do
res <- getMetadataWith (generateRequestByStructID "artificial intelligence" imt) (Just 10)
res <- getMetadataWith (generateRequestByStructID "artificial intelligence" imt) (Just 0) (Just 55)
case res of
(Left err) -> print err
(Right val) -> print $ _docs val
......@@ -17,10 +17,10 @@ import HAL.Doc.Struct
import Servant.API
import Data.Aeson
getMetadataWith :: Text -> Maybe Int -> IO (Either ClientError (Response Corpus))
getMetadataWith q l = do
getMetadataWith :: Text -> Maybe Int -> Maybe Int -> IO (Either ClientError (Response Corpus))
getMetadataWith q start rows = do
manager' <- newManager tlsManagerSettings
runHalAPIClient $ search (Just requestedFields) [q] Nothing l Nothing
runHalAPIClient $ search (Just requestedFields) [q] Nothing start rows
requestedFields :: Text
requestedFields = "docid,title_s,abstract_s,submittedDate_s,source_s,authFullName_s,authOrganism_s"
......
......@@ -46,8 +46,9 @@ type Structure doc = "ref" :> "structure"
-- Get's argument type
data SortField = Asc Text | Desc Text
deriving (Show)
instance ToHttpApiData SortField where
toUrlPiece (Asc t) = t <> " asc"
toUrlPiece (Asc t) = t <> " asc"
toUrlPiece (Desc t) = t <> " desc"
asc :: Text -> Maybe SortField
......@@ -58,10 +59,9 @@ desc = Just . Desc
-- Response type
data Response doc = Response
{
_numFound :: Integer,
_start :: Int,
_docs :: [doc]
{ _numFound :: Integer
, _start :: Int
, _docs :: [doc]
} deriving (Show, Generic)
L.makeLenses ''Response
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment