Arron
Arron

Reputation: 1164

Escape single quotes in Azure Search query

I am having a single quote in the data in filter condition.

Example: David O'Neil.

So If we have give this in Search Explorer as,

*&$count=true&$filter=Name eq 'David O'Neil'

How can we escape that single quote in the filter.

Update 1: If we use single quote to escape that one, 0 records are coming.

Update 2: Not able to use backslashes() also.

Upvotes: 6

Views: 3094

Answers (1)

Bruce Johnston
Bruce Johnston

Reputation: 8634

Single quotes in OData filters are escaped by doubling:

$filter=Name eq 'David O''Neil'

Since that resulted in zero records for you, I would guess there are other issues with your data (perhaps the apostrophe in O'Neil is not the ASCII character 39 but something more ornate?)

Upvotes: 13

Related Questions