People keep telling me to get with the times, and stop using vim as my primary text editor, but today I found a nice easy way to fast-find something. All you need to do is move the cursor over the piece of text you want to find and press Shift + 8; when you are not in INSERT mode.
Once you’ve set up a searchable behaviour on a doctrine model, and have indexed all the keywords on the model, you are going to want to build a search tool. First we should create a simple symfony form.
Yesterday I explained how to add the Searchable behaviour to a doctrine object, to I’ll cover that how to create a symfony task to re-index all the existing objects. The basic idea of the task is to retrieve all the objects from your database, mark them as dirty and re-save them. If you don’t mark them as dirty, nothing will update when you save, which is what you would expect from doctrine.
The searchable behaviour within Doctrine is a brilliant and powerful way to add a quick and simple search to your symfony code. The basics of this behaviour are to create an index table for your given model, which contains 4 things, a keyword, the field it was in, the position and the object id it was in.