5

I have two Facets I'm using for filtering via Azure Search: Revit's 2014 and Revit 2016 but both behave differently in the query.

Error 400 (Bad Request) when a query with "Revit's" is passed:

(search.in(Application, '7946ca7e-78d0-441a-b939-711cae340dc0||Revit\'s||2014', '<^>'))

However the query containing "Revit" (no apostrophe) works perfectly fine:

(search.in(Application, 'c691dc7f-1c08-4a1c-bc4b-db62b214a0b3||Revit||2016', '<^>'))

Azure Search documentation states that dangerous or reserved characters need to be escaped by adding a '\' before them and I'm doing just that but the error is still occurring.

The error message is:

"Invalid expression: ')' or ',' expected at position 125 in 'ContextId eq '72adad30-c07c-465d-a1fe-2f2dfac950a4' and (search.in(Application, 'c691dc7f-1c08-4a1c-bc4b-db62b214a0b3||Revit's||2014', '<^>'))'.\r\nParameter name: $filter"

I've tried solutions like replacing the ' with %27 or using:

name = name.replace(/'/g, escape);

None are working.

izSaad
  • 579
  • 6
  • 25

1 Answers1

0

The solution was simple, an apostrophe can be escaped simply by putting another one behind it. So in my example changing the string from "Revit's" to "Revit''s" did the trick. RFC 3986 encoding technique doesn't encode some characters including the apostrophe.

izSaad
  • 579
  • 6
  • 25