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