Gravatar for nicolas.a.slavik@accenture.com

Question by yonico, Jan 27, 2015 7:55 AM

Query summary in coveo

Hi - I need to show the number of results and the search word. How can I get this information and show it in the page. Can you please provide an example?

70 search results for "6 months"

1 Reply
Gravatar for mlaporte@coveo.com

Answer by Martin Laporte, Jan 27, 2015 7:57 AM

We expose a querySuccess event that is fired after each query. You can hook up to this event and then use jQuery to update the content of a custom <div> with whatever text you want. Also remove the stock QuerySummary component that does something like this OOTB.

Gravatar for nicolas.a.slavik@accenture.com

Comment by yonico, Jan 27, 2015 9:31 AM

I see the querySuccess but cant find examples of how to use it. The querySummary was removed. It doesnt get it inside event.

$('#searchBox').on('querySuccess', function(e, data) { var count = data.results.totalCount; … });

$('#searchBox').on('state:change:q', function (e, data) { alert('q has changed, the new value is: ' + data.value); });

Gravatar for nicolas.a.slavik@accenture.com

Comment by yonico, Jan 27, 2015 10:31 AM

I also tried "search" and doesnt get into it. See that the div we are using is:

Ask a question