Searching with Symfony and Doctrine

Doctrine Searchable

During testing, it was found that when a model/table is set to

    fields: [field001, field002]

a new table with _index appended to its name is added to the database (If ag_nationality were given the searchable attribute, we'd get a second table called ag_nationality_index). These tables are comprised at least four columns:

  • keyword, which corresponds to the value of the field we are indexing
  • field, which corresponds to the field we are indexing;
  • position, which corresponds to the position where the keyword is found (presumably, this would be useful if it's a large block of text being indexed)
  • [foreign_keys], of which there can be variable numbers and names, as each corresponds to one of the fields being indexed from the source table.

Aside from the large number of extra tables this will create, and the large amount of extra data, other issues were encountered as well. When running using a schema with tables set to searchable, fatal errors similar to the one below were encountered.

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes) in /Users/nils.stolpe/Sites/symtest/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Record.php on line 1529

This was overcome by upping the memory limit in *@php.ini@* from 128M to 256M, but could be a significant impediment for DoITT or other “laymen” operators attempting to prepare for or respond to an emergency (who has time to find the right *@php.ini@* file being used, then find the *@memory_limit@* line inside that file, then restart Apache, then build again, when fire is raining down from the sky and water is lapping at the fifth floor windows of local buildings?).

After that memory limit was upped, and ** was successfully run, it turned out that the *@_index@* tables were built, but the only field populated was *@[foreign_key]@*; all others were left empty. Tests were done from the frontend, to determine if data needed to run through Doctrine in order to fully populate entries, but this too resulted in only the *@[foreign_key]@* field being updated.

At this point, given the results of dev testing and the fact that searchable will not be supported in Doctrine 2, it seemed wisest to go back to the Zend Lucene search as our best option.

Reference Materials

QR Code
QR Code agasti:developer:searching_with_symfony_and_doctrine (generated for current page)