Gravatar for jschjolberg@awareweb.com

Question by jschjolberg, Jan 20, 2015 10:56 AM

How do you use the queryOverride option on a FacetRange component?

I'm using the FacetRange component with the JavaScript Search Framework and I'm wondering if you can give me an example of how to use the queryOverride option. What I need to do is have a query that looks at two index fields - something like this:

@IndexField1 >= rangeminvalue && @IndexField2 <= rangemaxvalue

Can you let me know how I might do this? Let me know if you need more info - thank you!

1 Reply
Gravatar for sbelzile@coveo.com

Answer by Sébastien Belzile, Jan 20, 2015 12:46 PM

Hi,

If you are asking for CoveoForSitecore:

  1. Open the CoveoFacetSlider.ascx file.
  2. After the div, add the following code in a script tag:

Coveo.$(function () { CoveoForSitecore.componentsOptions.[your slider unique ID].slider.queryOverride += "salut"; });

If you are using only the js search, see this page: https://developers.coveo.com/display/JsSearch/FacetRange+Component#FacetRangeComponent-queryOverride

You can add the query directly along with the data-something parameters or in the init call like this : $('#search').coveo('init', { "[your facet range id]" : { field : "@syssisze", slider : { queryOverride: [your query], } } })

Gravatar for jschjolberg@awareweb.com

Comment by jschjolberg, Jan 20, 2015 2:16 PM

Thank you. I'm using the JavaScript Search Framework. I'm having trouble getting code in the init call to modify my FacetRange components. I'm trying to test something simple like changing the start and end values. Here is my code for that:

$('#coveoSearchInterface').coveo('init', { FacetRange: { field: "@MyFieldName", slider: { start: 2, end: 9 } } });

This is having no affect on my FacetRange components. Is there something wrong with this code?

Gravatar for sbelzile@coveo.com

Comment by Sébastien Belzile, Jan 20, 2015 2:28 PM

The queryOverride is used to determine the slider boundaries. It will not affect the facetRange if you specify it's boundaries.

Gravatar for jschjolberg@awareweb.com

Comment by jschjolberg, Jan 20, 2015 2:44 PM

Thanks again - in the previous comment, I'm just trying to set the start and end options on my FacetRange components in this code. I'm not trying to do anything with the queryOverride option. I'm wondering if that code is correct. It should set the start and end options shouldn't it?

Gravatar for sbelzile@coveo.com

Comment by Sébastien Belzile, Jan 20, 2015 3:41 PM

What is written in your facet range div?

Gravatar for jschjolberg@awareweb.com

Comment by jschjolberg, Jan 20, 2015 4:15 PM

Here are the attributes on the div:

id="myFacetRange" class="CoveoFacetRange" data-title="Lift Capacity" data-field="@@MyFieldName" data-range-slider="true" data-enable-collapse="false"

Gravatar for sbelzile@coveo.com

Comment by Sébastien Belzile, Jan 20, 2015 4:21 PM

Try moving some of your attributes in the init call. I just tried some code similar to this and it started working when I moved the data-range-slider in the init call.

Ask a question