Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions test/search/facets.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ describe('Facets', function () {
this.searchobj.addRangeFilter(rangeField,start,end);
expect(this.searchobj.params.ranges[rangeField][start + ' TO ' + end])
.to.exist;
var rangeFacet = this.searchobj.params.ranges[rangeField];
expect(rangeFacet.hasOwnProperty(start + ' TO ' + end)).to.be.true;
expect(rangeFacet[start + ' TO ' + end].lb).to.equal(start);
expect(rangeFacet[start + ' TO ' + end].ub).to.equal(end);
}
);

Expand Down Expand Up @@ -183,4 +187,19 @@ describe('Facets', function () {
}
);

it('Range facet - validate processUrl', function(){
var rangeField = 'price_fq';
var start = 5;
var end = 10;
var filter = rangeField + ':[' + start + ' TO ' + end + '}';
var processedParams = this.searchobj._processURL({
filter: filter
});

var rangeFacet = processedParams.ranges[rangeField];
expect(rangeFacet.hasOwnProperty(start + ' TO ' + end)).to.be.true;
expect(rangeFacet[start + ' TO ' + end].lb).to.equal(start);
expect(rangeFacet[start + ' TO ' + end].ub).to.equal(end);
});

});
6 changes: 3 additions & 3 deletions unbxdSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -1063,9 +1063,9 @@ var unbxdSearchInit = function(jQuery, Handlebars){
&& this.defaultParams.ranges.hasOwnProperty(x)
&& this.defaultParams.ranges[x].hasOwnProperty(y)
&& this.params.ranges[x].hasOwnProperty(y)){
b.push(x + ':[' + this.params.ranges[x][y].lb + " TO " + this.params.ranges[x][y].ub + ']');
b.push(x + ':[' + this.params.ranges[x][y].lb + " TO " + this.params.ranges[x][y].ub + '}');
}else if(this.params.ranges[x].hasOwnProperty(y)){
a.push(x + ':[' + this.params.ranges[x][y].lb + " TO " + this.params.ranges[x][y].ub + ']');
a.push(x + ':[' + this.params.ranges[x][y].lb + " TO " + this.params.ranges[x][y].ub + '}');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's starts with square bracket & end with flower bracket?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

square bracket -> Include interval
flower bracket -> Exclude interval

Currently we are apply filter including both upper and lower Interval. But in facets response, it returns count of products under Start >= product < End

}
}

Expand Down Expand Up @@ -1265,7 +1265,7 @@ var unbxdSearchInit = function(jQuery, Handlebars){
for(var x = 0; x < filterStrArr.length; x++){
var arr = filterStrArr[x].split(":");
if(arr.length == 2){
arr[1] = arr[1].replace(/(^")|("$)/g, '').replace(/\"{2,}/g, '"').replace(/\\\"/g, '"').replace(/(^\[)|(\]$)/g, '');
arr[1] = arr[1].replace(/(^")|("$)/g, '').replace(/\"{2,}/g, '"').replace(/\\\"/g, '"').replace(/(^\[)|(\]$)|(\}$)/g, '');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change required?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Range facet in search metadata will now be in format filter: "price_fq:[30 TO 60}"
It will start with square bracket & end with flower bracket


var vals = arr[1].split(" TO ");
if(vals.length > 1){
Expand Down