views:

437

answers:

1

Hey, if anyone knows a simple answer to this, I don't have to wade through creating an extra index with escaped strings and crying my eyes out while littering my pretty code.

Basically, the Lucene search we have running cannot handle any non-letter characters. Space, percent signs, dots, dashes, slashes, you name it. This is higly infuriating, because I cannot make any search on items containing these characters, no matter wherever I escape them or not.

I have two options: Kill these characters in a separate index and strip them from the names I'm searching or stop goddamn searching.

+1  A: 

You can escape special characters using '/'. Lucene treats followings the following as special characters and you will have to escape those characters to make it work.

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

If you want to search "2+3", query should be "2/+3"

Jugs
Thank you. This is the correct answer (I foolishly tried to escape with backslash all the time). However we have long moved off from the Zend-managed Lucene index as it was a horrible god damn mess. Next time we'll break out a Solr instance and bypass all this hell.
John