handle 10000 package limit in the UI correctly (#99)
fixes #94 Co-authored-by: Samuel Dionne-Riel <samuel@dionne-riel.com>
This commit is contained in:
parent
a8b7faa398
commit
7a73578d7c
|
@ -392,7 +392,7 @@ makeRequest :
|
|||
-> Cmd Msg
|
||||
makeRequest options channel query from size =
|
||||
Search.makeRequest
|
||||
(makeRequestBody query from size)
|
||||
makeRequestBody
|
||||
("latest-" ++ String.fromInt options.mappingSchemaVersion ++ "-" ++ channel)
|
||||
decodeResultItemSource
|
||||
options
|
||||
|
|
|
@ -476,7 +476,7 @@ makeRequest :
|
|||
-> Cmd Msg
|
||||
makeRequest options channel query from size =
|
||||
Search.makeRequest
|
||||
(makeRequestBody query from size)
|
||||
makeRequestBody
|
||||
("latest-" ++ String.fromInt options.mappingSchemaVersion ++ "-" ++ channel)
|
||||
decodeResultItemSource
|
||||
options
|
||||
|
@ -540,4 +540,3 @@ decodeResultPackageHydraPath =
|
|||
Json.Decode.map2 ResultPackageHydraPath
|
||||
(Json.Decode.field "output" Json.Decode.string)
|
||||
(Json.Decode.field "path" Json.Decode.string)
|
||||
|
||||
|
|
|
@ -402,8 +402,13 @@ view path title model viewSuccess outMsg =
|
|||
model.from + model.size
|
||||
)
|
||||
++ " of "
|
||||
++ String.fromInt result.hits.total.value
|
||||
++ "."
|
||||
++ (if result.hits.total.value == 10000 then
|
||||
"more than 10000 results, please provide more precise search terms."
|
||||
|
||||
else
|
||||
String.fromInt result.hits.total.value
|
||||
++ "."
|
||||
)
|
||||
)
|
||||
]
|
||||
]
|
||||
|
@ -554,7 +559,7 @@ type alias Options =
|
|||
|
||||
|
||||
makeRequest :
|
||||
Http.Body
|
||||
(String -> Int -> Int -> Http.Body)
|
||||
-> String
|
||||
-> Json.Decode.Decoder a
|
||||
-> Options
|
||||
|
@ -562,14 +567,23 @@ makeRequest :
|
|||
-> Int
|
||||
-> Int
|
||||
-> Cmd (Msg a)
|
||||
makeRequest body index decodeResultItemSource options query from size =
|
||||
makeRequest makeRequestBody index decodeResultItemSource options query from sizeRaw =
|
||||
let
|
||||
-- you can not request more then 10000 results otherwise it will return 404
|
||||
size =
|
||||
if from + sizeRaw > 10000 then
|
||||
10000 - from
|
||||
|
||||
else
|
||||
sizeRaw
|
||||
in
|
||||
Http.riskyRequest
|
||||
{ method = "POST"
|
||||
, headers =
|
||||
[ Http.header "Authorization" ("Basic " ++ Base64.encode (options.username ++ ":" ++ options.password))
|
||||
]
|
||||
, url = options.url ++ "/" ++ index ++ "/_search"
|
||||
, body = body
|
||||
, body = makeRequestBody query from size
|
||||
, expect =
|
||||
Http.expectJson
|
||||
(RemoteData.fromResult >> QueryResponse)
|
||||
|
|
Loading…
Reference in a new issue