Skip to content

Commit 9c7b653

Browse files
author
Blair McKenzie
committed
pagination support in search
1 parent 8b41ef5 commit 9c7b653

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/lib/cloudsearch.cfc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ component {
370370
};
371371
}
372372

373-
public struct function search(string domain, string typename, string rawQuery, string queryParser="simple", string rawFilter, array conditions, array filters, numeric maxrows=10, boolean log=true) {
373+
public struct function search(string domain, string typename, string rawQuery, string queryParser="simple", string rawFilter, array conditions, array filters, numeric maxrows=10, numeric page=1, boolean log=true) {
374374
var csdClient = "";
375375
var searchRequest = createobject("java","com.amazonaws.services.cloudsearchdomain.model.SearchRequest").init();
376376
var searchResponse = {};
@@ -468,6 +468,7 @@ component {
468468
if (structKeyExists(arguments,"rawFilter") and len(arguments.rawFilter)){
469469
searchRequest.setFilterQuery(arguments.rawFilter);
470470
}
471+
searchRequest.setStart(arguments.maxrows * (arguments.page - 1));
471472
searchRequest.setSize(arguments.maxrows);
472473

473474
try {
@@ -492,6 +493,9 @@ component {
492493
stResult["filters"] = arguments.filters;
493494
}
494495
stResult["rawFilter"] = arguments.rawFilter;
496+
stResult["recordcount"] = hits.getFound();
497+
stResult["page"] = arguments.page;
498+
stResult["maxrows"] = arguments.maxrows;
495499

496500
for (hit in hits.getHit()){
497501
queryAddRow(stResult.items);

0 commit comments

Comments
 (0)