Gravatar for

Question by salpsx, Feb 13, 2018 10:52 PM

Geolocation Query string message when no results

Based on the query that is passed to coveo to return results geolocated near the coordinates passed...when there are no results, the querystring is left on the results page stating for example:

No results for $qf(function:'dist(@latitude, @longitude, 42.5006, -90.6646)', fieldName: 'distance') @distance<16093.44

Is there a recommended way to either pass the original value (the customer uses a kendo autocomplete to lookup city, state and country and the matched result in the autocomplete box's lat and long are grabbed to send into the Coveo query along with a proximity value in meters (meters to miles). The results just don't seem to make sense to the end user.

We are using Javascript Framework.


1 Reply
Gravatar for

Answer by François Lachance-Guillemette, Feb 14, 2018 1:22 PM

It looks like your query is not being interpreted as a query function ($qf) but instead in plain text.

My guess is that it is caused by the `enableQuerySyntax` parameter that is now `false` by default.

On the CoveoOmnibox component, set `enable-query-syntax="true"`. You can also add a hook on the buildingQuery Event and set the QueryBuilder's `enableQuerySyntax` property to `true` like the following:

Coveo.$$(document.getElementById("YOUR_SEARCH_INTERFACE_ID")).on(Coveo.QueryEvents.buildingQuery, function(args) {
    args.queryBuilder.enableQuerySyntax = true;

You should now see `enableQuerySyntax: true` in the body of your outgoing request.


Also, it looks like the result is added in the `q` part of the query, which is used to set what the user has entered in the search box. The QuerySummary component reads the `q` part to show the `No results for ...` message you have up there.

You should put your query function in the `aq` part instead.

Ask a question