Sunday, July 22, 2012

ORMSearch throws error without a field

If you get an error when performing an ORMSearch that looks something like:
Error occured while seaching indexes for entity myEntity: null.

Chances are you have not supplied a field to use in the search.  The Lucerne search engine behaves erratically when it doesn't have a field to search.  

You can do one of two things, 1) supply a lucerne style of search string which is in the form of field:search string, or 2) a simple string in the search string and a field (or list of fields) in the fields attribute. 

I had a lot of trouble identifying what was actually happening here, so I hope this helps.