Pankaj Yadav
Pankaj Yadav

Reputation: 169

ACS: search.in doesn't support special characters in odata filters syntax

Special characters are not working with search.in operator in ACS for example this doesn't fetch any value from ACS search.in(category, 'Books & reference'). I have also tried to encode the special characters as follows but still no luck.

search.in(category, 'Books%20%26%20reference')
search.in(category, 'Books %26 reference')
search.in(category, 'Books+%26+reference')
search.in(category, 'Books & reference')

The only way it works is using the eq operator as follows

category eq 'Books & reference'

but as per ACS documentation seach.in is more performant and also convenient when there are multiple values of the attribute to filter for example

search.in(category, 'Movies,Education,Tools')

is more convenient than using eq operator as follows

category eq 'Books' OR category eq 'Education' OR category eq 'Tools'

Upvotes: 0

Views: 377

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136126

Please try by changing:

search.in(category, 'Books & reference')

to

search.in(category, 'Books & reference', '|')

Essentially in the first, space is being treated as a delimiter. In the second, you are explicitly telling to use a pipe (|) as a delimiter.

Considering pipe character is no where in your search values, your category field is searched for Books & reference whereas in the first case, the search is performed for Book, &, and reference values in category field.

This is what the documentation say about the delimiters (emphasis mine):

A string where each character is treated as a separator when parsing the valueList parameter. The default value of this parameter is ' ,' which means that any values with spaces and/or commas between them will be separated. If you need to use separators other than spaces and commas because your values include those characters, you can specify alternate delimiters such as '|' in this parameter.

Upvotes: 1

Related Questions