Gravatar for

Question by Hussain Shaik, Feb 23, 2017 11:38 AM

Get search results directly by sending query

I need to get the results from coveo JS by sending query parameter. I am using coveo cloud and JS framework. I don't want to hook the event to search box.

Just pass the query and get the results as JSON and then process the results. Any help ?

1 Reply
Gravatar for

Answer by olamothe, Feb 23, 2017 12:31 PM

You can use the SearchEndpoint class exposed by the UI.

You can use the search method, and build the query.

A good way to build a query correctly is by using a QueryBuilder :

Example :

var endpoint = Coveo.SearchEndpoint.endpoints['default'];

var queryBuilder = new Coveo.QueryBuilder();

var query =; { 
   // you can iterate on data.results here;

There'se a lot of parameters you can set on the query builder (expression, advancedExpression, wildcards, groupBy, etc.). When you call build, you receive an IQuery ( ) which you can pass to the search method on the endpoint.

The expected data type and return type of each function is documented in the reference website links I added.

Gravatar for

Comment by Hussain Shaik, Feb 23, 2017 12:36 PM

Excellent.. This helps me lot. Thanks !!!

Ask a question