Gravatar for mark.angus@sitesystems.ca

Question by mark, Jul 28, 2015 10:56 AM

Facet change yes option in facet to true

Hi, I am using the Coveo JSFrameworks. I have a facet that shows Yes an No as custom fields set on the document. When I select Yes and refresh the page, it converts the Yes option to true. It only happens on the Yes option. When the No option is selected and page is refreshed, it remains as No.

How to I resolve this issue.

Thanks in advance.

Gravatar for slangevin@coveo.com

Comment by Simon, Jul 28, 2015 11:33 AM

Not sure I fully understand the configuration. The field itself is a boolean or you have two field, which are strings yes and no?

Gravatar for mark.angus@sitesystems.ca

Comment by mark, Jul 28, 2015 11:49 AM

Hi, the custom field is of type string. It either is Yes or No.

Name:CustomFilter
Type:String Metadata Name:CustomFilter
Default Value:No

When I select 'Yes' option in the facet and refresh the page, it changes the 'Yes', I selected to 'true'.

Gravatar for mlaporte@coveo.com

Comment by Martin Laporte, Aug 3, 2015 3:47 AM

I wasn't able to reproduce that. What version are you using?

Gravatar for mark.angus@sitesystems.ca

Comment by mark, Aug 4, 2015 8:32 AM

Coveo.version Object {lib: "0.9.873.20", product: "0.9.1123.0"}

1 Reply
Gravatar for mark.angus@sitesystems.ca

Answer by mark, Aug 11, 2015 12:45 PM

If the url parameter contains "Yes" as a option, the Coveo search framework converts it to "true". This causes problems for the Yes/No Facet.

eg: #f:@customfilter=[Yes] becomes #f:@customfilter=[true] because of the code below.

testIfBoolean

HashUtils.decodeArray = function (value) {
    value = value.substr(1);
    value = value.substr(0, value.length - 1);
    var array = value.split(",");

    for (var i = 0; i < array.length; i++) {
        var arrayValue = decodeURIComponent(array[i]);
        var testIfNumber = arrayValue[0] == "0" && arrayValue.length > 1 ? NaN : Number(arrayValue);
        var testIfboolean = Coveo.Utils.parseBooleanIfNotUndefined(arrayValue);
        array[i] = arrayValue;
        if (!isNaN(testIfNumber)) {
            array[i] = testIfNumber;
        } else if (testIfboolean != undefined) {
            array[i] = testIfboolean;
        }
    }
    return array;
};

How to do fix that?

Thanks in advance.

Ask a question