Mick
Mick

Reputation: 6864

Open Search Server v1.4 select query special characters

We're using Open Search Server v1.4. When the user enters a search for the text "Refrigerator temperature chart (5" we create a URL something like

http://10.192.16.160:8080/services/rest/select/search/<indexname/json?login=<login>&key=<apikey>template=search&query=Refrigerator%20temperature%20chart%20%285&start=0&rows=1000&filter=fileType%3afile&lang=ENGLISH

This fails with ...

HTTP Status 500 - org.apache.cxf.interceptor.Fault: com.jaeksoft.searchlib.SearchLibException: com.jaeksoft.searchlib.query.ParseException: org.apache.lucene.queryParser.ParseException: Cannot parse 'content:(Refrigerator temperature chart (5) OR content:("Refrigerator temperature chart (5") OR

So adding an escape character %5C before the open bracket fixes this query like so...

http://10.192.16.160:8080/services/rest/select/search/<indexname/json?login=<login>&key=<apikey>template=search&query=Refrigerator%20temperature%20chart%20%5C%285&start=0&rows=1000&filter=fileType%3afile&lang=ENGLISH

Can someone point me to some documentation that lists all the special characters that can be used in an Open Search select query that need to be escaped when entered as part of the search string?

Upvotes: 0

Views: 5915

Answers (2)

Xearle
Xearle

Reputation: 101

Yes you are right, characters listed in section "Escaping Special Characters" in the page you linked also need to be escaped in OpenSearchServer.

We recently released a fix allowing to escape those characters in query of type Search (field) for Searched fields configured with a pattern mode.

Previously escaping of characters was only available in query of type Search (pattern). (more information of these two kind of queries here: http://www.opensearchserver.com/documentation/tutorials/functionalities.html#two-kinds-of-queries)

Regards,

Alexandre

Upvotes: 1

Mick
Mick

Reputation: 6864

I believe Open Search Server is based on Lucene. The query syntax for the Lucene engine is described here...

http://lucene.apache.org/core/2_9_4/queryparsersyntax.html

Lucene supports escaping special characters that are part of the query syntax. The current list special characters are

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

To escape these character use the \ before the character. For example to search for (1+1):2 use the query:

\(1\+1\)\:2

Upvotes: 1

Related Questions