Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

400 Bad Request when performing RangeFacetFor

Vote:
 

Whenever I try to get a RangeFacet from Find, I'm getting a 400 Bad Request as response. My search is:

var prices = new List { new NumericRange(0, 500) };

var results = search.RangeFacetFor(x => x.SalePrice, prices.ToArray()).Take(0).GetResult();

If I remove the GetResult() I no longer get the error, but I have no clue why I do get it when I try and get the result.

Anyone have any advice?

Thanks

#141748
Nov 19, 2015 12:00
Vote:
 

What type are you seaching for? Can you show a little bit more of your code where the search variable is initialized?

#141850
Nov 23, 2015 9:17
Vote:
 

Hi Mattias

  All I have so far is the below:

 var search = SearchClient.Instance.Search<BaseVariant>();

                search = filters.Aggregate(search, (current, filterBuilder) => current.Filter(filterBuilder));

                SearchResults<BaseVariant> results = null;

                var prices = new List<NumericRange> { new NumericRange(0, 500) };

                results = search.RangeFacetFor(x => x.SalePrice, prices.ToArray()).Take(0).GetResult();

The BaseVariant class has an extension method called SalePrice, which I ensure is indexed.

Thanks

#141851
Nov 23, 2015 9:28
Vote:
 

Calling GetResult() would execute your query towards FINDs REST service. If you remove GetResult, you only have a query that never is executed, hence the error/no error.

Your range facet looks correct, can you running GetResult without the filter (2nd line)?

What type is your SalePrice field?

#141852
Nov 23, 2015 9:38
Vote:
 

Hi Mari

   Without the filter, it works.  Having added the filter back in, it still works!  Very strange, but it appears to work.

Thanks

Rob

#141853
Nov 23, 2015 9:45
Vote:
 

If BaseVariant is an EPiServer Content Type, try using GetContentResult instead of GetResult.

#141854
Edited, Nov 23, 2015 10:10
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.