Escape Special Characters for Lucene

893 views
Skip to first unread message

Jon Wynveen

unread,
Oct 23, 2012, 5:51:20 PM10/23/12
to rav...@googlegroups.com
I did a query with brackets ([]) in it and was returned a Lucene.Net.QueryParsers.ParseException, since the brackets are reserved characters for range queries.

Based on the quick search I did, Lucene has a parser to escape those characters: http://www.javalobby.org/java/forums/t86124.html. Should Raven be using that by default, or are we as the user expected to escape our queries?

Jon Wynveen

unread,
Oct 23, 2012, 5:58:41 PM10/23/12
to rav...@googlegroups.com
Should have searched here for an answer before posting: https://groups.google.com/forum/?fromgroups=#!searchin/ravendb/escape$20special$20characters/ravendb/WABevNcXkfA/Xva00ftV23UJ

Is there anyway to set a query to escape all search terms by default? Something like:

_ravenSession.Advanced.LuceneQuery<object, SiteSearchIndexTask>().UsingDefaultParser(RavenQuery.Escape)

Oren Eini (Ayende Rahien)

unread,
Oct 24, 2012, 1:20:29 AM10/24/12
to rav...@googlegroups.com
Do NOT use Where() for that, if you use the default WhereEquals, etc API for Lucene Query, it will escape the values for you.

Jon Wynveen

unread,
Oct 24, 2012, 9:22:33 AM10/24/12
to rav...@googlegroups.com
Good to know. Thanks!
Reply all
Reply to author
Forward
0 new messages