HI I have a field to be searched which contains ch...
# community-help
c
HI I have a field to be searched which contains character ")" how can i escape it For eg : field :["testexample(1)"] If i give this i get the error "error": "Could not parse the filter query."
f
This has to do with how parentheses are handled in
filter_by
clauses. It expects a clause inside it and then cannot parse the result. Try to use braces for this use case e.g
testexample{1}
Copy code
curl --location --globoff --request GET 'localhost:8108/collections/store/documents/search?q=s&query_by=name&filter_by=name%3A[store{2}]' \
--header 'Content-Type: application/json' \
}'
This returns it as expected
h
@Chandar Venkata Rama If your filter value has special characters, you should enclose your value inside backticks like ``testexample(1)``
👍 2
f
If your filter value has special characters, you should enclose your value inside backticks like ``testexample(1)``
Would there be a way to escape special characters with the backslash character as well? e.g.
textexample\(1\)
h
No, only backticks are supported. From docs https://typesense.org/docs/27.0/api/search.html#filter-parameters
```Escaping Commas:
You can also filter using multiple values and use the backtick character to denote a string literal: category:= [
Running Shoes, Men
, Sneaker].```
Maybe the headline should say
Escaping Special Characters
instead of just
Escaping Commas
1
j
Yeah, let's update the wording in the docs
f
c
Related to this i came across another issue , I have field values like chandar-v-r chandarvr So when i search field :["chandar-v-r"] it returns both the records, that means its ignoring the hyphen and considering both values matching But the concern i have is if i include hyohen in symbols_to_index , i need to drop the collection and recreate , Do we have any other alternative ?
j
You could create a new collection with the updated schema, and reindex your data in it. You can also set up an alias to do a zero downtime switch to the new collection.