Recently, in one of our major Coveo renderings, there was a splurge of new requirements. Well, no huge surprise there I think. When powerful people meet in the same room, new ideas do come by, not such a good news to us developers who have scratched their brains and pulled up hours to wrap up the initial implementation. Although, I believe it is a good venue when time is on your side to learn something new. :)
This is exactly what happened to us, the requirement sounds pretty simple, but took me few hours to find an optimum solution which solves the problem, but, also would not involve too many changes to existing logic in play.
Goal - Get all the results that match the filters(facets) selected by end user with out the default pagination applied (Coveo has default pagination and only pulls the values entered in Number of results value given on the rendering properties). After few hours of going over Coveo documentation, I found something though completely not the same as what I was looking for, it kind of sparked the similar wave of implementation.
I almost always start a Q&A either to confirm my thoughts or to see if there are any other ways to accomplish the same. In this case, what i was going for just felt right and Coveo team member confirmed the same. You can follow the trail here.
https://answers.coveo.com/questions/10368/do-we-have-allnot-limited-to-resultsperpage-result.html
So, basically to achieve what I was looking for, you need to fire a parallel query with exact same filters based on user interaction and simply change the results to an upper bound. It would have been nice to actually set it to Totalresults, I have not tried that, but, could work when you get the value from the correct variable.
Here is a snippet -
Coveo.$('#<%= Model.Id %>').on(Coveo.QueryEvents.querySuccess,function(e, args){
var query = args.query;
query.numberOfResults = 2;
//Do any other modifications on the query
Coveo.SearchEndpoint.endpoints["default"].search(query).done(function(data) {
//do any other logic on the data up here
}
});
});
That is it, we have everything we need plus a handler over all results. I am pretty sure it would come up often hopefully it helps any one else.
Happy problem solving folks. :)
This is exactly what happened to us, the requirement sounds pretty simple, but took me few hours to find an optimum solution which solves the problem, but, also would not involve too many changes to existing logic in play.
Goal - Get all the results that match the filters(facets) selected by end user with out the default pagination applied (Coveo has default pagination and only pulls the values entered in Number of results value given on the rendering properties). After few hours of going over Coveo documentation, I found something though completely not the same as what I was looking for, it kind of sparked the similar wave of implementation.
I almost always start a Q&A either to confirm my thoughts or to see if there are any other ways to accomplish the same. In this case, what i was going for just felt right and Coveo team member confirmed the same. You can follow the trail here.
https://answers.coveo.com/questions/10368/do-we-have-allnot-limited-to-resultsperpage-result.html
So, basically to achieve what I was looking for, you need to fire a parallel query with exact same filters based on user interaction and simply change the results to an upper bound. It would have been nice to actually set it to Totalresults, I have not tried that, but, could work when you get the value from the correct variable.
Here is a snippet -
Coveo.$('#<%= Model.Id %>').on(Coveo.QueryEvents.querySuccess,function(e, args){
var query = args.query;
query.numberOfResults = 2;
//Do any other modifications on the query
Coveo.SearchEndpoint.endpoints["default"].search(query).done(function(data) {
//do any other logic on the data up here
}
});
});
That is it, we have everything we need plus a handler over all results. I am pretty sure it would come up often hopefully it helps any one else.
Happy problem solving folks. :)
No comments :
Post a Comment