@@ -103,12 +103,19 @@ def item_collection(
103
103
base_url = str (kwargs ["request" ].base_url )
104
104
105
105
with self .client .start_session () as session :
106
- collection_children = self .item_table .find (
107
- {"collection" : collection_id }, session = session
108
- ).sort (
109
- [("properties.datetime" , pymongo .ASCENDING ), ("id" , pymongo .ASCENDING )]
106
+ collection_children = (
107
+ self .item_table .find ({"collection" : collection_id }, session = session )
108
+ .limit (limit )
109
+ .sort (
110
+ [
111
+ ("properties.datetime" , pymongo .ASCENDING ),
112
+ ("id" , pymongo .ASCENDING ),
113
+ ]
114
+ )
110
115
)
111
116
117
+ matched = self .item_table .count_documents ({"collection" : collection_id })
118
+
112
119
for item in collection_children :
113
120
response_features .append (
114
121
self .item_serializer .db_to_stac (item , base_url = base_url )
@@ -120,7 +127,7 @@ def item_collection(
120
127
context_obj = {
121
128
"returned" : count if count <= 10 else limit ,
122
129
"limit" : limit ,
123
- "matched" : len ( response_features ) or None ,
130
+ "matched" : matched or None ,
124
131
}
125
132
126
133
return ItemCollection (
@@ -296,6 +303,8 @@ def post_search(
296
303
.sort (sort_list )
297
304
)
298
305
306
+ matched = self .item_table .count_documents (queries )
307
+
299
308
results = []
300
309
links = []
301
310
@@ -329,7 +338,7 @@ def post_search(
329
338
context_obj = {
330
339
"returned" : count if count <= 10 else search_request .limit ,
331
340
"limit" : search_request .limit ,
332
- "matched" : len ( results ) or None ,
341
+ "matched" : matched or None ,
333
342
}
334
343
335
344
return ItemCollection (
0 commit comments