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
|
-> Cmd Msg
|
||||||
makeRequest options channel query from size =
|
makeRequest options channel query from size =
|
||||||
Search.makeRequest
|
Search.makeRequest
|
||||||
(makeRequestBody query from size)
|
makeRequestBody
|
||||||
("latest-" ++ String.fromInt options.mappingSchemaVersion ++ "-" ++ channel)
|
("latest-" ++ String.fromInt options.mappingSchemaVersion ++ "-" ++ channel)
|
||||||
decodeResultItemSource
|
decodeResultItemSource
|
||||||
options
|
options
|
||||||
|
|
|
@ -476,7 +476,7 @@ makeRequest :
|
||||||
-> Cmd Msg
|
-> Cmd Msg
|
||||||
makeRequest options channel query from size =
|
makeRequest options channel query from size =
|
||||||
Search.makeRequest
|
Search.makeRequest
|
||||||
(makeRequestBody query from size)
|
makeRequestBody
|
||||||
("latest-" ++ String.fromInt options.mappingSchemaVersion ++ "-" ++ channel)
|
("latest-" ++ String.fromInt options.mappingSchemaVersion ++ "-" ++ channel)
|
||||||
decodeResultItemSource
|
decodeResultItemSource
|
||||||
options
|
options
|
||||||
|
@ -540,4 +540,3 @@ decodeResultPackageHydraPath =
|
||||||
Json.Decode.map2 ResultPackageHydraPath
|
Json.Decode.map2 ResultPackageHydraPath
|
||||||
(Json.Decode.field "output" Json.Decode.string)
|
(Json.Decode.field "output" Json.Decode.string)
|
||||||
(Json.Decode.field "path" Json.Decode.string)
|
(Json.Decode.field "path" Json.Decode.string)
|
||||||
|
|
||||||
|
|
|
@ -402,9 +402,14 @@ view path title model viewSuccess outMsg =
|
||||||
model.from + model.size
|
model.from + model.size
|
||||||
)
|
)
|
||||||
++ " of "
|
++ " 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
|
||||||
++ "."
|
++ "."
|
||||||
)
|
)
|
||||||
|
)
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
, viewPager outMsg model result path
|
, viewPager outMsg model result path
|
||||||
|
@ -554,7 +559,7 @@ type alias Options =
|
||||||
|
|
||||||
|
|
||||||
makeRequest :
|
makeRequest :
|
||||||
Http.Body
|
(String -> Int -> Int -> Http.Body)
|
||||||
-> String
|
-> String
|
||||||
-> Json.Decode.Decoder a
|
-> Json.Decode.Decoder a
|
||||||
-> Options
|
-> Options
|
||||||
|
@ -562,14 +567,23 @@ makeRequest :
|
||||||
-> Int
|
-> Int
|
||||||
-> Int
|
-> Int
|
||||||
-> Cmd (Msg a)
|
-> 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
|
Http.riskyRequest
|
||||||
{ method = "POST"
|
{ method = "POST"
|
||||||
, headers =
|
, headers =
|
||||||
[ Http.header "Authorization" ("Basic " ++ Base64.encode (options.username ++ ":" ++ options.password))
|
[ Http.header "Authorization" ("Basic " ++ Base64.encode (options.username ++ ":" ++ options.password))
|
||||||
]
|
]
|
||||||
, url = options.url ++ "/" ++ index ++ "/_search"
|
, url = options.url ++ "/" ++ index ++ "/_search"
|
||||||
, body = body
|
, body = makeRequestBody query from size
|
||||||
, expect =
|
, expect =
|
||||||
Http.expectJson
|
Http.expectJson
|
||||||
(RemoteData.fromResult >> QueryResponse)
|
(RemoteData.fromResult >> QueryResponse)
|
||||||
|
|
Loading…
Reference in a new issue