Commit f5c6e917 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] API Search POST.

parent 38362aeb
...@@ -59,6 +59,7 @@ newtype SearchQuery = SearchQuery ...@@ -59,6 +59,7 @@ newtype SearchQuery = SearchQuery
{ query :: String { query :: String
, databases :: Array Database , databases :: Array Database
, corpus_id :: Maybe Int , corpus_id :: Maybe Int
, files_id :: Array String
, offset :: Maybe Int , offset :: Maybe Int
, limit :: Maybe Int , limit :: Maybe Int
, order :: Maybe SearchOrder } , order :: Maybe SearchOrder }
...@@ -70,6 +71,7 @@ defaultSearchQuery = SearchQuery ...@@ -70,6 +71,7 @@ defaultSearchQuery = SearchQuery
{ query: "" { query: ""
, databases: allDatabases , databases: allDatabases
, corpus_id: Nothing , corpus_id: Nothing
, files_id : []
, offset: Nothing , offset: Nothing
, limit: Nothing , limit: Nothing
, order: Nothing } , order: Nothing }
...@@ -83,7 +85,8 @@ instance searchQueryToQuery :: ToQuery SearchQuery where ...@@ -83,7 +85,8 @@ instance searchQueryToQuery :: ToQuery SearchQuery where
[ QP.keyFromString k /\ Just (QP.valueFromString $ show v) ] [ QP.keyFromString k /\ Just (QP.valueFromString $ show v) ]
instance encodeJsonSearchQuery :: EncodeJson SearchQuery where instance encodeJsonSearchQuery :: EncodeJson SearchQuery where
encodeJson (SearchQuery {query, corpus_id}) encodeJson (SearchQuery {query, corpus_id, files_id})
= "query" := query = "query" := query
~> "corpus_id" := fromMaybe 0 corpus_id ~> "corpus_id" := fromMaybe 0 corpus_id
~> "files_id" := files_id
~> jsonEmptyObject ~> jsonEmptyObject
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