Commit cc773005 authored by Mael NICOLAS's avatar Mael NICOLAS

fix#1

search should always be called with `docid` and `label_s` if you don't want more
than this just use `basicSearch`
parent 52fe9140
...@@ -8,11 +8,13 @@ import Servant.Client ...@@ -8,11 +8,13 @@ import Servant.Client
import HAL.Client import HAL.Client
basicSearch = search ["docid", "label_s"]
main :: IO () main :: IO ()
main = do main = do
manager' <- newManager tlsManagerSettings manager' <- newManager tlsManagerSettings
res <- runClientM res <- runClientM
(search ["docid"] ["docType_s:(THESE OR HDR)"] (asc "docid") (Just 1) (Just 2)) (basicSearch ["docType_s:(THESE OR HDR)"] (asc "docid") (Just 1) (Just 2))
(mkClientEnv manager' $ BaseUrl Https "api.archives-ouvertes.fr" 443 "") (mkClientEnv manager' $ BaseUrl Https "api.archives-ouvertes.fr" 443 "")
case res of case res of
(Left err) -> print err (Left err) -> print err
......
...@@ -20,12 +20,6 @@ import Control.Lens as L (makeLenses) ...@@ -20,12 +20,6 @@ import Control.Lens as L (makeLenses)
type HALAPI = Search :<|> Structure type HALAPI = Search :<|> Structure
type Structure = "ref" :> "structure"
:> QueryParam "fq" Text
:> QueryParam "fl" Text
:> QueryParam "rows" Int
:> Get '[JSON] Response
type Search = "search" type Search = "search"
-- fl determine which fields will be returned it can be a list of fields or * -- fl determine which fields will be returned it can be a list of fields or *
:> QueryParams "fl" Text :> QueryParams "fl" Text
...@@ -40,6 +34,13 @@ type Search = "search" ...@@ -40,6 +34,13 @@ type Search = "search"
:> QueryParam "rows" Int :> QueryParam "rows" Int
:> Get '[JSON] Response :> Get '[JSON] Response
type Structure = "ref" :> "structure"
:> QueryParam "fq" Text
:> QueryParam "fl" Text
:> QueryParam "rows" Int
:> Get '[JSON] Response
-- Get's argument type -- Get's argument type
data SortField = Asc Text | Desc Text data SortField = Asc Text | Desc Text
deriving (Show) deriving (Show)
...@@ -92,6 +93,8 @@ structure :: Maybe Text -- fq ...@@ -92,6 +93,8 @@ structure :: Maybe Text -- fq
-> Maybe Text -> Maybe Text
-> Maybe Int -- rows -> Maybe Int -- rows
-> ClientM Response -> ClientM Response
-- search should always have at least `docid` and `label_s` in his fl params
search :: [Text] -- fl search :: [Text] -- fl
-> [Text] -- fq -> [Text] -- fq
-> Maybe SortField -- sort -> Maybe SortField -- sort
......
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