zend-search-luceneescaping

Zend Lucene fails all searches with special characters


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.


Solution

  • 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"