Escaping Special Characters

(from github.com/freestyle68)
Hi,

using Elasticsearch special character

+ - && || ! ( ) { } [ ] ^ " ~ * ? : \

Fess give the message: The given query is invalid.

For the standard user it’s too frustrating to insert the query between double quotes or insert the escape before.

Have you considered to escape this characters on Fess?

Thank you

(from github.com/marevol)
Since some of them are a query operator, Fess cannot decide whether it should be escaped.
So it’s difficult to do that… but any idea is welcome.

(from github.com/freestyle68)
By far the more frequently used are/ or : as date separators.

I know that : is a query operator.

And also / ?

I forgot to insert in the list / as a problematic character.

(from github.com/marevol)
/ is not an operator.
A solution might be to send an escaped query again if InvalidQueryException occurs…

(from github.com/freestyle68)
my question was too much broad: forget : that is an operator and focus on / only:

a query like

2/20/2015

give error, so the user must insert an escape before / or make the query

"2/20/2015"

It would be easier for the standard user insert the query simply as

2/20/2015

Is there a solution now for escaping the character / in a query?

For us, the slash is a typical sign when identifying documents. @freestyle68 gave date as an example.

@shinsuke So there isn’t a solution yet for searching with a slash?

No update. Fess is OSS. Any contribution is welcome.

What is escaping is done, if the query does not contain valid field name or sort parameter followed by semicolon? Kinda limited escaping.

If the query does not contain a field name with semicolon, then those “problematic” characters are escaped, which causes invalid query error.

  • and ? would still act as wildcards.

This may not cover all cases, but if this escaping would be optional?
You could turn it on, and accept that not all special queries are not working any more.

Fess depends on Lucene’s query parser. If you want to change the behavior, you need to modify QueryHelper.