Gravatar for nicolas.a.slavik@accenture.com

Question by yonico, Feb 9, 2015 12:40 PM

Query customization

Hi - we are doing a facet with query customization and was wondering if you can provide examples of how to specify a query for the queryOverride on Group By Parameters.

Also would like to specify filters after doing the following on groupby.

data.queryBuilder.groupByRequests.push({ "field": "@fagelistcomputed86456","overrideQuery":query, "sortCriteria":"Occurrences", "maximumNumberOfValues": 1000, "injectionDepth": 5000 });

After doing this, we should set the results on the following event: $("#search").on("querySuccess", function(e,data){

What's the way to send the result to this event?

1 Reply
Gravatar for mlaporte@coveo.com

Answer by Martin Laporte, Feb 10, 2015 3:40 AM

I'm not 100% certain I understand your question properly.

First, in your sample code you're pushing a value for overrideQuery, but in fact the field is called queryOverride. This value is a query expression that will be used to compute the group by. It is optional, if you don't specify it the main query expression is used instead (that's what happens most of the time). One typical usage for this option is to have a group by computed for an expression different than the one yielding the query results. Even more typical is putting there the full query expression EXCEPT the filter linked to a specific facet, in order to get the list of values matching the current query + filters from other facets.

Your code otherwise seems correct. Typically you want to remember the index where you added your Group By request (check length of groupByRequests before calling push), since the group by results come in the same order as the requests. E.g. the results for your GroupBy will be at the same index as your request in the results JSON, in the groupByResults. This data indeed is typically processed during the querySuccess event.

Ask a question