@@ -56,7 +56,7 @@ object SearchCommand extends Command with SprayJsonSupport with DefaultJsonProto
56
56
val baseUri = Uri (config.server)
57
57
val prettyParam = Map (" pretty" -> " " )
58
58
val searchUri = baseUri.withPath(baseUri.path + " /search" ).withQuery(akka.http.scaladsl.model.Uri .Query (prettyParam))
59
- val responseFuture = Marshal (Query (query)).to[RequestEntity ] flatMap { entity =>
59
+ val responseFuture = Marshal (Query (query, config.limit )).to[RequestEntity ] flatMap { entity =>
60
60
Http ().singleRequest(HttpRequest (uri = searchUri, method = HttpMethods .POST , entity = entity))
61
61
}
62
62
@@ -66,7 +66,7 @@ object SearchCommand extends Command with SprayJsonSupport with DefaultJsonProto
66
66
entity.dataBytes.runFold(ByteString (" " ))(_ ++ _).map { body =>
67
67
body.utf8String
68
68
}
69
- case resp @ HttpResponse (code, _, _, _) => {
69
+ case resp@ HttpResponse (code, _, _, _) => {
70
70
error(config)(" Request failed, response code: " + code)
71
71
resp.discardEntityBytes()
72
72
Future (" " )
@@ -91,11 +91,25 @@ object SearchCommand extends Command with SprayJsonSupport with DefaultJsonProto
91
91
}
92
92
93
93
val unmarshalled = Await .result(unmarshalledFuture, Duration .Inf )
94
- information(config)(s " Found ${unmarshalled.size} item(s). " )
94
+ val capMessage = {
95
+ config.limit match {
96
+ case Some (limit) if (limit <= unmarshalled.size)
97
+ => s " Results may be capped by result limit set to $limit. "
98
+ case None if (unmarshalled.size >= 50 )
99
+ => " Results may be capped by default limit of 50 returned results. Use --limit to extend the result set."
100
+ case _
101
+ => " "
102
+ }
103
+ }
104
+ information(config)(s " Found ${unmarshalled.size} item(s). $capMessage" )
95
105
reportResult(config)(unmarshalled)
106
+
107
+
96
108
information(config)(f " Query took $took%.2fs. " )
97
109
}
98
110
}
99
111
100
- case class Query (query : String , pretty : Option [Boolean ] = Some (true ))
112
+ case class Query (query : String ,
113
+ limit : Option [Int ] = None )
114
+
101
115
}
0 commit comments